I want to see how well some curves fit a data set. If a curve doesn't fit after 100 iterations, I get the error cvmit. How do I test for and handle this error within my code?


1 Answer 1


I think Check will do it, e.g.:

    (* function that may throw error *) 
    Fit[ data, funs, vars ],
    (* what to do if error is thrown *)
    Print["No convergence within 100 iterations!"]; 
    (* limit to only this error *)

Of course, you could be using other functions to do the fitting (instead of Fit). You could also do things like Quiet the error message, in case you want to handle the convergence problem gracefully.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.