Quick one, sometimes my curvefits will throw a NaN (Not a Number?) warning after completion. I can look back and see which fit produced the NaNs. I've written some error catching code which looks for and reanalyzes fits that give NaN values so that there are no NaNs in the final fits, but the program still gives me the warning after it ends, (even though the waves with the NaN have been overwritten). I would like to stop this (as it makes it seem like my program in throwing an error, when in fact it catches it and corrects it.) This is purely cosmetic, but if it's possible, I'd still like to do it.
The second half of the error says this:
"The fitting function returned NaN for at least one X value."
I apologize if this has already been discussed, I'm not having any luck with the search.
'1116 22fit_coef'[0]= {0,0,0,0} -- Blank wave
'1116 22fit_coef'[0]= {224.48,-47.485,1522.63,0} -- Bad coefficients
/////////REANALYZE//////////
'1116 22fit_coef'[0]= {224.48,-47.485,1522.63,0} -- Print bad one again when it's caught in the error checking
'1116 22fit_coef'[0]= {224.48,-47.485,1522.63,0} -- Print bad one again before curvefit
'1116 22fit_coef'[0]= {195.609,35.9991,1557.44,5.53417} --Print corrected ones after curvefit
So they are actually getting changed. Usually these are just caused if one side of the "window" for the curve fit is stuck on top of a point of noise. Guess I could just do error checking before and check the window boundaries, but that would require more code.
In your function, create a variable V_FitError and check it after the fit. Like this:
Variable V_FitError=0 CurveFit ... if(V_fitError) // Code to do whatever you want to do in this case. endif
There are some things that don't count quite as errors that you may want to know about. They are covered by V_FitQuitReason. Learn about these and other special variables:
DisplayHelpTopic "Special Variables for Curve Fitting"
Anyway, I just wanted to make sure that the bad fits WERE in face being reanalyzed.
Code goes generally like this. (Just for debugging, normal program doesn't print anything besides 'Finished'.)
Print coeffWave //Prints the W_coef
CurveFit gauss ... stuff stuff
Print coeffWave
If (error checking)
Print "/////ANALYZING/////"
Print coeffWave
goOn = 0
else
goOn = 1
endif
Results are as follows.
'1116 22fit_coef'[0]= {0,0,0,0} -- Blank wave
'1116 22fit_coef'[0]= {224.48,-47.485,1522.63,0} -- Bad coefficients
/////////REANALYZE//////////
'1116 22fit_coef'[0]= {224.48,-47.485,1522.63,0} -- Print bad one again when it's caught in the error checking
'1116 22fit_coef'[0]= {224.48,-47.485,1522.63,0} -- Print bad one again before curvefit
'1116 22fit_coef'[0]= {195.609,35.9991,1557.44,5.53417} --Print corrected ones after curvefit
So they are actually getting changed. Usually these are just caused if one side of the "window" for the curve fit is stuck on top of a point of noise. Guess I could just do error checking before and check the window boundaries, but that would require more code.
July 10, 2013 at 12:42 pm - Permalink
CurveFit ...
if (V_fitError)
// Code to do whatever you want to do in this case.
endif
There are some things that don't count quite as errors that you may want to know about. They are covered by V_FitQuitReason. Learn about these and other special variables:
DisplayHelpTopic "Special Variables for Curve Fitting"
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 10, 2013 at 05:01 pm - Permalink