How to Graph a fitting function for initial guessing of the variables

Hi,

 

I am making a panel that fits the complicated function and graphs. I am using FuncFit. Basically, it is an extended version of the curve fit module with more functions according to my needs. 

I want to make a graph for the initial guess of different variables but I am not sure what is the best way of doing it as I am kinda new to igor. 

Any help will be appreciated. 

In the curve fitting dialog there is the 'graph now' button, so if your function can be written as a standard fit function you can use that.

In your own code you would have to create a wave for plotting the fit (probably one that you will reuse to hold the results of the fitting), then initialise that wave by feeding your coefficient wave containing the initial guesses to your fitting function. For a simple fit, something like this:

wave dataWave, w_coef // w_coef is filled with estimates for fit coefficients
duplicate /o DataWave $"fit_"+nameofwave(DataWave) /wave=fitWave
fitWave=MyFitFunction(w_coef, x)

 

In reply to by tony

Thanks a lot for the information. I want to know how the values of x are assigned. When I am trying to implement as you suggested, it is giving me a plot but at wrong q values. Can you please suggest what I am doing wrong or what I should do?

 

NVAR HC_amp,HC_Rc,HC_pol,HC_Rough,HC_Back
            SetActiveSubwindow Panel0#G0
            Make/D/O root:HC_coeff  = {HC_amp,HC_Rc,HC_pol,HC_Rough,HC_Back}
            Make/D/o fitwave
            fitWave=HC_Fit_Func(HC_coeff, q)
        AppendtoGraph/W=#/C=(1,9611,39321) fitwave
        ModifyGraph lsize(fitwave)=2

 

In reply to by shankar.dutt

Make/D/o fitwave

This creates 1D wave with the default number of points (128) and an x-scaling of deltaX=1. So fitwave[5] and fitwave(5) each refer to the sixth point of the wave. Use setscale to adjust the x scaling so that x values match those of your data.

fitWave=HC_Fit_Func(HC_coeff, q)

fitwave has only rows, not columns. In the wave assignment p refers to the row (point) number, and q to the column number (which in this case is always 0). You should use x instead of q (assuming that the wave is scaled and your function takes x as the independent variable).

DisplayHelpTopic "setscale"

Perhaps it would be a good idea to take the guided tour? Go to Help > Getting Started for an explanation of these topics.