LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to add Levenberg Marquardt.vi's input port?

My work is fitting a math model y=f(x1,x2),but it is a nonlinear problem,I can measure y,x1 and x2,LABVIEW 7 Express provides the Levenberg Marquardt vi,it has only one input port,how can I add one??
PS:My system is XP sp2
THANK YOU!
0 Kudos
Message 1 of 13
(6,134 Views)
Levenberg-Marquardt only fits 1D data, you want 2D data.

You should be able to transform your 2D data into 1D data, e.g. Add 1000 (or whatever) to x2, then call the fitting as y=f(x1+x2). If your fitting function, use divide x by 1000 using quotient and remainder and you'll get (x1=remainder, x2=integer quotient).

You could also probably rewrite the stock LabVIEW code for 2D data and save them under a new name, none of the VIs are protected. (see this example).
Message 2 of 13
(6,123 Views)
I'm sorry that I can't understand your answer very well.
I've seen the url that you gave me,I think it has little with my subject.
My empirical math model is :
y=(a+b*x1+c*x1^2+d*x1^3+e*x1^4+f*x1^5+....)*x2+A*x1*exp(B*x1)
y,x1 and x2 can be measured, a,b,c,d,e,f......A,B is the unknown coefficient.
The first part is a polynomial problem, the number of polynomial is not determined,it can be modified at random.The second part is a non-linear problem
Would you please help me modify the Levenberg Marquardt.vi?
I'm a freshman in labview,thanks.


Labviw 7.0 & winxp
0 Kudos
Message 3 of 13
(5,869 Views)
altenbach
I'm studying your 2DQuadraticPlaneFit_002.vi,there are lots of questions.
can you tell me the main arithmetic of the vi?
The math model :
y=(a+b*x1+c*x1^2+d*x1^3+e*x1^4+f*x1^5+....)*x2+A*x1*exp(B*x1)
can be applied here? how?
Thanks a lot.
0 Kudos
Message 4 of 13
(6,113 Views)
The core of the fitting is based on the stock Lev-Mar VI but it assumes that the function outputs all y values in one swoop (The stock VI requires the function to be calculated one point at a time, which makes it more restrictive and unsuitable more many models). All the skeleton code is plain Levenberg-Marquardt. It optimizes a set of function parameters to produce a closest match between a calculate and an experimental dataset (based on chi-square criterium).

You definitely have to make some modifications, but most of what you need is in place.

You need for example the following:

  • Provide a way for the function subroutine to get the x1, and x2 inputs so it can calculate y according to your mathematical model.

  • Note that the "2DNonlinear Lev-Mar Fit.vi" already has an array input labeled x, however it is not used in my particular simplified application because the subVI creates a fixed square lattice of know size. You need to add a connector to the function to receive all your x1, x2 values so it can output a calculated y-array to be compared with your experimental y data for all the same x1, x2 combinations. It does not matter how you design these inputs, it only matters that the function outputs a 1D array of the correct length. For example you could interleave your x1, x2 pairs, send them along the x array input then decimate them in the function VI.

  • Write a function subroutine for your model.

  • As mentioned, it should receive the x1, x2 pairs so you need to add a connector and change the template. In addition, it also needs to receive an array of your fitting parameters. I would arrange them in the following order:
    (A, B, a, b, c, d, e, f ...).
    This way, the function can determine the order of the polynomial straight from the lenght of the parameter array and should directly work for any choose order you want. Simply truncate this array at runtime if you want to lower the polynomial order. 🙂
    The output is the y-array.

  • Create a user interface to pick good initial guesses for the paramteres

  • Create a graph to display your y data for all your measured points overlayed with simulated data using your the function subroutine above and your parameter guesses. Now manually adjust the parameters until there is reasonable agreement. Levenberg-Marquardt does not guarantee results if the initial guesses are way off or unreasonable. It really depends on the model how robust the fitting is (In my example, it is very robust and the initial guesses can be zero for all parameters). Once you're in the ball park, call the fitting VI using these initial guesses.

    Maybe this can get you in the right direction. It would probably take me at least an hour to do implement the above suggestion, but I'm currently quite busy with other things. If you get stuck, please give me an experimental data set and I'll play with it a bit. It does not look very hard, but it would be weird flying blind without real data for testing. If you want, you can contact me further via the e-mail address given on the front panel of the discussed VI.
    Message 5 of 13
    (6,101 Views)
    altenbach
    Appreciate for your reply and help!!

    I'll try my best to modify the model according to your advice, if I have question,how can I mail you?

    Message Edited by Support on 04-10-2005 08:41 PM

    0 Kudos
    Message 6 of 13
    (6,078 Views)
    As mentioned, my UCLA e-mail address is listed on the front panel of the example program 2DQuadraticPlaneFit_002.vi discussed above, you can use that to contact me. 🙂

    I don't like to post my e-mail address on any public page such as this because they often get harvested by spammers using automated means. I recommend NOT to post e-mail addresses in public. (For more information, have a look at a related experiment carried out by a web site or e.g. the honeypot project.)
    0 Kudos
    Message 7 of 13
    (6,073 Views)
    ......it makes me worried.But I can't edit my reply:(
    0 Kudos
    Message 8 of 13
    (6,065 Views)
    On each post, you can select in the upper right corner the following:

    "Options...Report to a Moderator"

    You will get a window where you can e.g. request that the post be edited. Still, this forum gets also mirrored to the comp.lang.labview newsgroup, where it can no longer be changed easily, but at least it won't show here any longer.

    I don't know how NI handles this, but some sites have certain mechanisms in place to either stop or slow down automatic harversters. I would expect that the Lithium boards have some measures as part of their security features.
    Message 9 of 13
    (6,056 Views)
    Hello Xeulang,
    As mentioned earlier, the Levenberg-Marquadt.vi only fits 1D data. If you cannot transform your 2D data into 1D data you can use a formula node to perform mathematical operations if you know the formula you want to use (Functions Pallette >> All Functions >> Structures). You can find more information on the formula node by pressing Ctrl + H. This will bring up the context help window and will display a small help file for each item you hover your mouse over. It will also give you a link to the more comprehensive help file that you can find in the help menu under VI function and How to help.

    Regards,
    Chris J
    National Instruments
    0 Kudos
    Message 10 of 13
    (5,826 Views)