Question about fitting coefficients.

Hi.
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.
2014-10-24 오후 8.03.24.png (62.47 KB)
The fit coefficients are stored by default in the wave W_Coef in the current data folder but are overwritten each time you do a new fit. If you want to store such data after each fit (assuming that the number of fit coefficients is constant) you can execute something like this after each fit to create a summary wave:

function FitCoefSummary()
    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.

MatrixOP/O ParameterA = row(W_CoefSummary, 0)^t

Hi there,

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.

#pragma rtGlobals=3     // Use modern global access method and strict wave access.

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!
vmmr5596 wrote:

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?


In your second function, do something equivalent to this ...

    string coeffname
    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