LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Levenberg-Marquardt, error

Solved!
Go to solution
Hello all, I'm currently trying to implement a nonlinear curve-fit routine in LabView (Nonlinear Curve Fit.vi, Levenberg-Marquardt). I'm trying to find a best fit for a given exponential decay, and the fitting model is passed to the Nonlinear Curve Fit VI through a VI. However, I don't want to implement the model as simple function, but instead I want to describe the model with a Runge-Kutta ODE solver. I do that, so I can later on implement more complex mechanism and models that do not have an analytical solution. When i try to run the optimization the Levenberg-Marquardt algorithms runs a few times, and then returns "Error -20041 Analysis: The system of equations cannot be solved because the input matrix is singular." This error seems to occur quite often, but the other topics here couldn't solve my problem unfortunately. Any suggestions on how to solve the problem are highly appreciated 🙂
0 Kudos
Message 1 of 12
(7,323 Views)

Hi,

 

did you try the suggested steps in the following KB

http://digital.ni.com/public.nsf/allkb/36448BDBE67D99048625660C0000BDF0?OpenDocument

Best

0 Kudos
Message 2 of 12
(7,246 Views)
Hi, thank you for your suggestion. The problem is, that my inital coefficients work perfectly fine. Only after a few function calls the algorithm crashes and I have no idea why it does so only after it already started. Best regards
0 Kudos
Message 3 of 12
(7,225 Views)

Since your model contains an iterative procedure you get accumulation of errors and jitter in the result. This means that your partial derivatives are most likely not good. (to calculate the partial derivatives, the function is evaluated with two microscopically different parameter values and that slope is most likely quite random.)

 

You can easily do the experiment and see how the partial derivative depend on the exact parameter value.

0 Kudos
Message 4 of 12
(7,217 Views)
When I calculate the derivate of my function numerically and manually, the derivates seem to be 0. I'm calculating my function with 2 slightly different parameters and after my Runge-Kutta VI the two functions are the same. The Levenberg-Marquardt VI probably does the same which lead to the fact, that I can't optimize my function. Did I get you right about that point? Best regards
0 Kudos
Message 5 of 12
(7,193 Views)
Solution
Accepted by Hobgoblin

The partial derivatives are not always zero and if you had some way to calculate the partial derivatives in some analytical way, you could include that in the model, of course.

 

There are fitting algorithms that don't rely on partial derivatives, such as Nelder-Mead (downhill simplex). Curiously, we just had a related discussion a few days ago, which prompted me to release my nonlinear fit replacements that implements Nelder-Mead instead. As you can see, if you replace your current nonlinear curve fit with my version, the fit proceeds nicely. 😄

 

NM-RK-Fit.png

 

 

Message 6 of 12
(7,179 Views)

Hi altenbach,

 

thanks for your help. Your VI seems to work perfectly fine, even for some more complicated problems. Very nice!

 

Best regards

0 Kudos
Message 7 of 12
(7,153 Views)

This is a LV2011 version of my example above for users who are not able to open my version.

0 Kudos
Message 8 of 12
(6,895 Views)

hi hobgoblin

I think you uploaded the v15 again. I am unable to open on LV2011

 

bp
0 Kudos
Message 9 of 12
(6,890 Views)

Oh ok, sorry. 

 

Try this one

 

Best regards

0 Kudos
Message 10 of 12
(6,883 Views)