LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Nonlinear curve fit function

Solved!
Go to solution

hello everybody:

I am a new guy here and at the same time a new learner for labview. My laboratory need to fit data which is nonlinear, so i choose to use the nonlinear curve fitting VI model. But when i run the VI, the error is that:NI_Gmath.lvlib:LM formula string function.vi:7290001,or other error displayments. I have tried many times, but unfortunately failed. The problem may be the formular function expression. By the way, the design of VI is not mine, it is from NI forum. Any constructive suggestions will be welcomed.

The formular :

y=y0+(nr*cos(a))+a1*(x-w1)/((x-w1)^2+l1^2)+a2*(x-w2)/((x-w2)^2+l2^2)  

Actually, the formular is very long, i just write down a few ones.

Download All
0 Kudos
Message 1 of 29
(6,368 Views)

Hi caplee,

 

what is the error code of the error. I test your vi and obtained error code -20041 which means some matrix in vi is singular. I replace zero value in your inital paramters to non-zero value and then it works without error. Did you obtained the same error code?

 

Best regards,

CaravagGIO 

0 Kudos
Message 2 of 29
(6,342 Views)

i see your answer, i will test it right now. 

0 Kudos
Message 3 of 29
(6,334 Views)

sorry, it did not work. i do not understand :"replace the zero in the initial parameters with non-zero parameters". can you give me your testing parameters? the initial parameters need to guess first before the fitting runs. but i do not know how to guess, my teacher is out now, so can i see your parameters?

0 Kudos
Message 4 of 29
(6,327 Views)

First you should tell me if you have the same error 🙂 . The initial parameters is the array of 3 values [-4E-6, 11310, 0]. The last value was set to zero. I change this value to one. That's all.

0 Kudos
Message 5 of 29
(6,319 Views)

i have the same error too. i forget to tell you that: the formular is not what you see in the VI. it is y=y0+(nr*cos(a))+a1*(x-w1)/((x-w1)^2+l1^2)+a2*(x-w2)/((x-w2)^2+l2^2) . the number of the unknown parameters which need me to fit are nine or so. 

0 Kudos
Message 6 of 29
(6,316 Views)

could you please provide your actual vi with initial values you are using? I am not able to replicate the error. thanks

0 Kudos
Message 7 of 29
(6,306 Views)

i do not have now. i just test the vi again, the error code is -23082,which means: bracket problem at the beginning.

if i can find,message u later

 

0 Kudos
Message 8 of 29
(6,301 Views)

A bracket error is probably due to a typing mistake in entering the formula.

 

It is often useful to plot the data calculated by the formula and to compare that to a plot of the data ta the same scale. This method often allows rapid identification of errors in the formula which cause the function to be very different from what you expect.

 

In many cases the formula parsing results in the fitting process to take much longer than the version which uses a VI to calculate the function values.

 

Lynn

0 Kudos
Message 9 of 29
(6,257 Views)

OK, the formula:

 

y=y0 + (nr*cos(a)) + a1*(x-w1)/((x-w1)^2+l1^2) + a2*(x-w2)/((x-w2)^2+l2^2) 

 

Can never be fit with a unique solution, because y0, nr, and a are obviously 100% correlated and simply add up to a single offset in the data. I would leave the term (nr*cos(a)) out for the time being.

0 Kudos
Message 10 of 29
(6,246 Views)