Manual creation of hold conditions are not working properly in FuncFit.
Subhamoy
I have written a procedure for curve fitting for which the I'm using a wave to hold coefficients. In the procedure, according to the entries in Hold wave the input transforms.
//-------- Holding parameter values while fitting ---------------------
Wave Hold
String HH="\""
Variable k=0
Do
HH += num2str(Hold[k])
k +=1
while(k<numpnts(Hold))
HH += "\""
FuncFit/H=HH/NTHR=0 MyCurveFit CoefWave DataWave[start, end] /X={x1Wave, x2Wave} /D /C=Constraints /R=residual
Wave Hold
String HH="\""
Variable k=0
Do
HH += num2str(Hold[k])
k +=1
while(k<numpnts(Hold))
HH += "\""
FuncFit/H=HH/NTHR=0 MyCurveFit CoefWave DataWave[start, end] /X={x1Wave, x2Wave} /D /C=Constraints /R=residual
Suppose I have 3 coefficients, K0, K1 and K2. Thus to hold K1 HH should be "010". Taking print of HH is same but the problem is during fitting it applies to K2.
For HH="100", K1 becomes constant and not K0. I have tested it by taking Hold as Text wave also but no luck. Interestingly, when I directly write HH="010" rather than using the above codes, it is working fine (applies to K1).
Any help will be highly appreciated.
You are adding "s before and after the hold string. I think that is your problem. That will make the hold value of K0=".
I think the "s would only make sense if your code was: FuncFit/H=$HH instead of FuncFit/H=HH
April 20, 2020 at 11:21 pm - Permalink
In reply to You are adding "s before and… by olelytken
Thanks for your reply @olelytken. It worked.
The Input in FuncFit should be /H="010". Now if I omit "s at the start and end then HH=010 nd not "010". That's why I was doing like this. But I forgot that HH is already contains string.
April 21, 2020 at 03:29 am - Permalink
Right- that flag takes a "string expression". A quoted literal string is one form of string expression, and the contents of a string variable is another form. You can also make up a string expression from a combination like
FuncFit/H=("11"+moreStuff) ...
April 21, 2020 at 10:58 am - Permalink
I thought that there might be a way to build the string as this:
HH[0,numpnts(hold)-1] = num2str(hold[p])
Is string indexing not passed implicitly this way?
April 21, 2020 at 04:20 pm - Permalink
If HH is a string variable, it doesn't have a p function on the LHS.
April 21, 2020 at 05:10 pm - Permalink