Manual creation of hold conditions are not working properly in FuncFit.

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

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

 

In reply to 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.

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

String moreStuff = "10"
FuncFit/H=("11"+moreStuff) ...

 

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?