LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using VI instead of formula string for non linear curve fit vi

New to LabVIEW (currently have version 8.6)- I've gone through a couple of curve fitting tutorials that were really helpful; I was able to use the 'nonlinear curve fit.vi' function with f(x,a) described by formula string option, but I cannot figure out how to use this function with f(x,a) being described by VI option. Any help would be great.

0 Kudos
Message 1 of 9
(4,229 Views)

I do not have version 8.6 handy at the moment and some things have changed over several versions, so this may not be completely accurate.

 

The VI needs to be a strict match to the reference connected to the curve fit VI input because it calls the function VI through VI Server.  In some versions of LV the detailed help file has a link to a template or example VI which has the correct connector pane. If your version has that, follow the link to get the VI. Save it under a new name and modify it to generate your function but do not change the connector pane.  Generating the partial derivatives is optional.  If you do generate them, make sure that you put them in the correct order in the output. If your function is difficult to differentiate numerically, providing the derivatives is useful. Generally the fitting functions do pretty well at calculating them.  Again that may have been one fo the things which has improved in recent versions.

 

Lynn

0 Kudos
Message 2 of 9
(4,218 Views)

Open the example finder. There are a few simple examples that you show you all you need. If you get stuck, show us your code.

0 Kudos
Message 3 of 9
(4,209 Views)
Is it still the case that the nonlinear LM example uses the deprecated version of the VI? That was a classic.
0 Kudos
Message 4 of 9
(4,205 Views)

Yes, the totally obsolete "Nonlinear Lev-Mar Exponential Firtting.vi" and "Paramenter fitting LM.vi" examples is still in there. 😮

 

Howver there are quite a few examples for the new style (8.0+) nonlinear fitting. ("Fit ellipse.vi", "Fit gaussian surface with offset.vi", "Fit sum of 3 2Dgaussians with offset.vi" (which is not really a 2D problem here), and "Fit sum of 3 Gaussians with offset.vi")

 

Alternatively, have a look at my examples posted here. 😄

0 Kudos
Message 5 of 9
(4,195 Views)

Hello altenbach,

 

If I could, I would like to pick your brain.

(I'm using LabVIEW 2011 in the Dev Suite)

 

Summary of problem:

I need to determine how to perform a Levenberg-Marquardt fit for a formula model that has multiple independant variables. I see the "Non-linear Curve Fit.vi" in LabVIEW that implements the LM method, but it only seems to support one independent variable.

 

I don't know enough about your "Multicomponent EPR Spectra" program to determine if

As I stated earlier, I am trying to come up with a fit method for the following equation:

9-7-2012 12-42-47 PM.png

 

I was given this equation from someone that determined that this has a good chance of fitting the experimental data.

a,b,c,d,f,g, & h are the parameters or fitting coefficients.

V, I, and phi are the independent variables.

I was given a set of instructions on an iterative approach in performing the fit by seeding values and then holding them constant while I add terms and fit those with seed values.

1. Fit the a,b,c terms first by seeding them with 1's

2. Add the exponential term and fit with a,b,c held and seeding d and f

3. Add the phi^2 and phi^3 terms and fit with a,b,c,d,f held constant and seed g & h.

 

Do you have any thoughts on how to implement fitting with multiple independent variables?

 

Thankyou,

Tim

0 Kudos
Message 6 of 9
(4,148 Views)

Yes, Whatever 1D array you wire to the x-input is not used by the fitting procedure at all and arrives unchanged at the model VI where you can interpret it any way you want.

 

For example you could take a 2D array with three rows or columns (one for I, V, and Phi, for example) and reshape it to a 1D arrray of 3x lenght. In the model VI you simply reshape it back to the original 2D array and calculate your model function.

 

Alternatively, you could interleave three 1D arrays and wire to to the x input. In the model you decimate it back into the three arrays.

 

Ove ther years I have posted plenty of examples that use these methods. For example see the two links in this message.

0 Kudos
Message 7 of 9
(4,128 Views)

Hello, I have same issue too. I'm not sure how to connect this Lev-Mar vi input to the graph. What should I write in the model description? and why the best non linear fit can not connect to the input of graph. Thank you.. 

0 Kudos
Message 8 of 9
(3,177 Views)

Hi aidasaufi,

 

Attached is a picture that should help you connect the Lev-Mar input to the XY-graph. The issue in your method is that you are trying to make an array of arrays. LabVIEW does not allow this. However, if you make an array of clusters this is supported in LabVIEW.

 

Hope this helps!

0 Kudos
Message 9 of 9
(3,127 Views)