08-27-2012 09:41 AM
I am trying to use lev mar to fit data to an equation. The equation has two parameters that I am trying to solve for, but it also has one constant variable that I do not want lev mar to use in optimization. How can I use this constant value in my fitting equation?
Solved! Go to Solution.
08-28-2012 11:29 AM
Hi Peter,
This tutorial for curve fitting in LabVIEW should be very helpful for you: http://www.ni.com/white-paper/7669/en
There is also an example for using Lev-Mar to fit data to an equation in the LabVIEW example finder. If you go to help-->find examples, and then search "Nonlinear Lev-Mar Exponential Fitting," you will be able to find Nonlinear Lev-Mar Exponential Fitting.vi.
Hope this helps!
Dayna P.
Applications Engineer
National Instruments
08-28-2012 01:54 PM
Try using 'Constrained Nonlinear Curve Fit.vi'. In the 'parameter bounds' control if the 'parameter maximum' and 'parameter minimum' for a given parameter are the same value that parameter is constrained to have that value.
-Jim
08-29-2012 08:33 AM
This vi has no instructions on how to input the equation I want to fit to- it makes a vague and useless refrance to a VI that impliments the fitting model, but does not show how to use or even access it.
The Lev-Mar vi that I am using now requires a model description string for the fit equation, but the only variables I can use are fit parameters. The tutorial above does not even mention using known variables for this vi.
08-29-2012 09:36 AM
My fault. Forgot the constrained Lev-Mar does not have a polymorphic instance for formula strings. Take a look at the attached VI. This shows a constrained exponential fit using the formula interface.
-Jim
08-29-2012 09:51 AM
It is also possible to use the 'substitute variables' to substitute a constant for one of the variables. Then the unconstrained version of Lev-Mar can be used. Attached is the same exp fit done both ways.
-Jim
08-29-2012 09:52 AM
'substitute variables.vi' that is.
08-29-2012 02:51 PM
Thank you, that seems like it should work. However, When I run the vi it returns the exact parameters that I used as inputs, and the Fit Y values are all NaN. It did not throw any of the errors that I would have expected if it was just a bad fit (I would expect 'wrong model equation', or at least to just get inacurate fit params back). It just ran as if nothing happened. Do you have any idea what might cause it to behave this way?
thanks
08-29-2012 02:54 PM - edited 08-29-2012 03:03 PM
Not sure how to delete my previous post, but I figured out why it wasn't throwing errors.
12-10-2012 02:30 AM - edited 12-10-2012 02:32 AM
Hello Peter,
I have the same probleme as you with my labview file and the Levmar function: When I run the vi it returns the exact parameters that I used as inputs, and the Fit Y values are all NaN.
How did you correct the problem?
Nicolas