LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

levenberg Marquardt

Solved!
Go to solution
Hi,
 
I want to use the Levenberg-Marquardt algorithm to extract the best fit co-efficients for the following equation:
 
Y = r*((L+dL)/(W+dW))
 
I'm getting confused looking at the the non-linear curve fit VI. I'm not sure what to connect to the input terminals.
 
Input terminals: data, f(x,a), Y, X, Weight, initial coniditions, termination
 
My co-efficients will be = (r, dL, dW) so my initial co-efficients will be something like (500, 0, 0).
I have an array of Y values which depend on L and W so the Y input terminal is ok.
Weight and termination should be ok.
I'm not entirely sure what to connect to the input terminal X however since my Y value depends on 2 variables L and W.
 
Any help appreciated,
 
LMS17
 
 
 
 
 
0 Kudos
Message 1 of 10
(6,378 Views)
You need to use the VI model, not the formula version and be a bit creative. 🙂
 
For the VI model, the X input is optional and its size does not need to match the y array so you can use it any way you want. All you need to do is know what's there and handle it accordingly inside the model VI.
 
For 2D data, you could for example interleave the L and W arrays and wire it to X. Inside the model, you decimate X to get L and W back and calculate Y using the fitting parameters.
 
(You could also use the variant data input to relay the L and W arrays to the model so y can be calculated.)
 
See how far you get. Good luck!
 
Message 2 of 10
(6,374 Views)
Solution
Accepted by lms17

cheers, that worked like a dream!

 

LMS17

0 Kudos
Message 3 of 10
(6,344 Views)

Hi

 

I have the same problem. Could you give me an example how to fit 2-D data?

Thanks

 

Cindy

 

 

0 Kudos
Message 4 of 10
(6,138 Views)
Have a look at my old examples, e.g. the links in this post.
Message 5 of 10
(6,133 Views)

Altenbach:

 

I browsed through the thread and I cannot find the example.  I have two vectos of independent variables X, Y, a object vector Z to fit, and also a model function which includes sin and cos functions. So I guess I will need to use a 3D Levenberg Marquardt algorithm.

 

Do you have an example like that?

 

Thanks

 

Cindy

0 Kudos
Message 6 of 10
(6,125 Views)
What is your LabVIEW version?
0 Kudos
Message 7 of 10
(6,103 Views)

:

 

I have 7.1.

 

Thanks for the help

 

Cindy

 

0 Kudos
Message 8 of 10
(6,090 Views)

akang wrote:

I have 7.1.


Ouch!!!!

 

The NI implementation of Levenberg marquardt prior to LabVIEW 8.0 was not very useful. Things would be significantly easier if you had LabVIEW 8.0 or higher.

 

Very long ago, I wrote a few tools to get around the pre-8.0 limitations, and you can find quite a few examples if you search the forum. Here are two examples that deal with a 2D array of independent data.

 

http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=82900#M82900

 

(this one assumes that the xy data forms a grid and that the model VI knows the pattern) 

 

 

http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=115758#M115758

 

(this one accepts the x and y array as a single interlaced 1D array of twice the lenght)

 

You can probably adapt these to your problem. See how far you get and please ask if anything is not clear.

0 Kudos
Message 9 of 10
(6,083 Views)

Altenbach:

 

Thanks for the information, It is very helpful.

 

Cindy

0 Kudos
Message 10 of 10
(5,968 Views)