Assess whether the fit gives error in a function

I am performing curve fit in a defined function for 2D arrays. Each column in the 2D wave is fit one by one in a for loop. For some of the columns, the fit likely fails since it gives message box at the end of the run saying that

`While executing FuncFit, the following error occurred: singular matrix or other numeric error`

as shown in the image below.

I want to find out for which columns the FuncFit fails. Is there a way to return the fit status from FuncFit or the fit status stored in a variable. It seems that the documentation does not make this clear.



Take a look at this curve fitting help topic: DisplayHelpTopic "Special Variables for Curve Fitting"

In particular, you need the variable V_FitError. You might also want V_FitQuitReason, but the singular matrix error will be caught by V_FitError.

To use it, you must create the variable and set it to zero. After the fit, check it for non-zero:

Variable V_fitError = 0
FuncFit ....
if (V_fitError)
.... do something with the error ....


Thank you for the direction. I checked the help topic as suggested and found it very useful. 

If you expect occasional fit errors in a loop, you might want to suppress these error messages and handle them in code only. For this you can use the try-catch environment. Here is some dummy code:

    FuncFit/Q myFitFunc W_coef, myData; AbortOnRTE
    if (V_AbortCode == -4)                  // AbortOnRTE triggered
        variable cfError = GetRTError(1)        // 1 to clear the error
        Print "Error:", GetErrMessage(cfError,3)    // debug

You can read more here:

DisplayHelpTopic "try-catch-endtry"