Issues with curve fitting

Description

I have written a procedure to calculate various sequential sets of data which may range from 20 -100 waves at various times. The procedure is written in a way that as it runs it generates a wave which is displayed followed by fitting this wave by a custom written equation. The fitting parameters of this equation are initialized and it perfectly fits the data set. As procedure proceeds further it now generates new data set which is appended on the previous graph and is then subsequently fitted by the same equation taking the coefficients of previous fit as the initial guess parameters. The procedure works very fine, however, sometimes at larger times, it seems difficult for the equation to fit the data, rather it writes the same values as that parameters of the previous fit. when I try to fit it outside the procedure, the same thing happens again, it seems difficult for the equation to fit date sets.
I would want to know what kind of precaution should I consider to enable efficient fitting. If anyone needs a snippet of the procedure I can provide so.
Are you checking V_FitError and V_FitQuitReason to make sure that the fit finished successfully? You need something like this:

Function DoMyFits()

    Variable V_FitError
    Variable V_FitQuitReason
    Variable i
    for (i = 0; i < numfits; i += 1)
        V_FitError = 0
        V_FitQuitReason = 0
        FuncFit ...
        if (V_FitError)
            ... handle error here ...
        endif
        if (V_FitQuitReason)
            ... handle other cases here ...
        endif
    endfor

end

Read about it in Igor's help:

DisplayHelpTopic "Special Variables for Curve Fitting"



Instead of doing the heavy code-writing lifting, you might try out our Batch Curve Fit package. To learn more, open the demo: File->Example Experiments->Curve Fitting->Batch Curve Fitting Demo.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com