Question about fitting coefficients.
Jinhyung Kim
I'm a newbie of Igor Pro.
Help me please.
I fitted some wave by using new fit function. f(x)=Acos(bx+p)exp(-gx)
The new fit function have four coefficients of A, b, g and p. (I attached screenshot)
I fitted 20 waves.
Finally, I want to make new wave consists of fitted coefficient.
How can I return the fitted coefficient value?
One more question..
As I attached screenshot,
The Data browser can't show +- sign, it shows diamond and question mark.
How can I fix it?
I use Igor Pro 6.35A5 on Yosemite and main language of OS X is Korean.
Thank you very much.
wave/Z W_coef
Wave/Z W_coefSummary
if(!WaveExists(W_CoefSummary)) // make a summary wave if it does not exists
Duplicate/O W_Coef W_CoefSummary
endif
variable nFits = DimSize(W_CoefSummary, 1)
Redimension/N=(-1, nFits+1) W_CoefSummary // add one column to the summary wave
W_CoefSummary[][nFits] =W_Coef[p]
end
Then use MatrixOP to extract a wave with the individual parameters, e.g.
October 24, 2014 at 04:58 am - Permalink
October 25, 2014 at 05:03 pm - Permalink
I'm trying to do something very similar to what is discussed here.
I wrote the following two procedures that fit a set of data according to a custom function. The problem is that, as ChrLie pointed out, the coefficient wave gets rewritten after every fit. Would anyone have a good way to implement the above code to mine?
The first function(SpanoFit) defines the fitting procedure for a single wave. The second function(SpanoFitAll), does the same thing as the first one but cycles through a designated number of waves.
Function SpanoFit(w1,xwave,cwave)
Wave w1,xwave,cwave
String outputName="Spano_" + NameOfWave(w1)
Duplicate /O w1 $(outputName)
Wave output=$(outputName)
FuncFit/N=1 /L=1231 /H="1010010" Spanov6 cwave w1[600,775] /X=xwave /D
output= Spanov6(cwave,xwave)
End
Function SpanoFitAll(w1,xwave,cwave,fnum)
String w1
Wave xwave,cwave
Variable fnum
Variable i
String neww1
for(i=1; i<=fnum; i=i+1)
neww1 = w1+num2str(i) +"_bl_smth"
SpanoFit($(neww1),xwave,cwave)
endfor
End
Thanks for the help in advance!
August 1, 2016 at 12:09 pm - Permalink
In your second function, do something equivalent to this ...
for ...
neww1 = ...
coeffname = "fitcoeff_" + neww1
SpanoFit(...)
wave W_coef
duplicate/O W_coeff $coeffname
endfor
return 0 // good programming practice to put a return value
This will create one wave per fit rather than putting the coefficients in a matrix.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
August 1, 2016 at 04:51 pm - Permalink