LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

lev mar input constant

Solved!
Go to solution

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?

0 Kudos
Message 1 of 13
(4,581 Views)

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

0 Kudos
Message 2 of 13
(4,562 Views)

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

0 Kudos
Message 3 of 13
(4,552 Views)

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.

0 Kudos
Message 4 of 13
(4,539 Views)

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

0 Kudos
Message 5 of 13
(4,531 Views)
Solution
Accepted by topic author Peter_O'Connell

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

0 Kudos
Message 6 of 13
(4,528 Views)

'substitute variables.vi' that is.

0 Kudos
Message 7 of 13
(4,527 Views)

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

 

 

0 Kudos
Message 8 of 13
(4,514 Views)

Not sure how to delete my previous post, but I figured out why it wasn't throwing errors.

0 Kudos
Message 9 of 13
(4,513 Views)

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

0 Kudos
Message 10 of 13
(4,441 Views)