LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Non Linear Curve Fitting

Solved!
Go to solution

I am trying to fit to a nonlinear equation in the form y = (a*b*x)/(b+x) to solve for a and b. Up till now I have been solving for a and b by using the Solver add in in Excel, but would like to do this in LabVIEW to speed up the post processing time. In the attached VI is a constant that is like the data I will be getting from my full program. I have already done my normal post processing to see what a and b should be for this data set. They are listed in the VI as well. Any suggestions would be appreciated.    

 

I would like to do it without using Express VI’s if possible.

 

Thanks!!!

Download All
0 Kudos
Message 1 of 8
(4,809 Views)

As a quick first comment, your X and Y inputs are backwards, I think!


However, swapping them and solving gives 

a: 0.00377929

b: 9715.5

which isn't exactly what you wanted!

 

However, the mean of the y-y_predicted is 0.

Is it a possible second solution?

 

Edit: I checked the mean fractional error avg((y_predicted - y)/y * 100) and the result is 34%. That doesn't sound great to me, but I don't know...


GCentral
Message 2 of 8
(4,776 Views)

I agree with cbutcher (about X and Y being backwards, and about the "wrong answer" being returned).  Curiously, the answer doesn't change if I move the Starting Point, nor if I remove the (0, 0) data entries, suggesting that the algorithm isn't (by default) converging well.  I'm currently a little sleep-deprived, so can't do much more tonight ...

 

Bob Schor

0 Kudos
Message 3 of 8
(4,771 Views)

Haha. Yes I did have them backwards. However this is still not giving me the correct solution. Would using an optimization function be a better solution?

0 Kudos
Message 4 of 8
(4,728 Views)
Solution
Accepted by topic author Dealcs

If I was confronted with that type of problem,

I would try to use this: http://zone.ni.com/reference/en-XX/help/371361M-01/gmath/con_nonlin_curve_fit/

instead of : http://zone.ni.com/reference/en-XX/help/371361H-01/gmath/nonlinear_curve_fit/

 

Moreover, there's this nicely written guide from altenbach about non-linear curve fitting:

http://forums.ni.com/t5/Nonlinear-Fitting/Practical-Nonlinear-Fitting/gpm-p/3511655

 

 

 

 

 

 

Message 5 of 8
(4,713 Views)

The results returned from LabVIEW have a lower error than the results returned from Excel. Using the "Goodness of Fit.vi" the SSE from the Excel results is 0.2358401. This agrees with the 'Error' value in the spreadsheet. The SSE from the LabVIEW results is 0.2331595.

 

Message 6 of 8
(4,702 Views)

@DSPGuy wrote:

The results returned from LabVIEW have a lower error than the results returned from Excel. Using the "Goodness of Fit.vi" the SSE from the Excel results is 0.2358401. This agrees with the 'Error' value in the spreadsheet. The SSE from the LabVIEW results is 0.2331595.

 


 

Moreover, EXCEL has a rounding issue occurring at about 1E-9, which doesn't affect you, if you stay in the EXCEL world e.g.

copy coefficients from EXCEL 2003 to EXCEL 2016.

But it will heavily affect you e.g. if you calculate regression coefficients in EXCEL and than want to use those in LabView

 

Also, if you use EXCEL to calculate regression tasks, EXCEL 2003,2007 results may differ from EXCEL 2013, 2016

 

excel_regression_version.PNG

 

0 Kudos
Message 7 of 8
(4,673 Views)

I used the last link that alexderjuengere suggested to get me to a point that I am happy with. Using the "Goodness Fit.VI" I feel pretty confident in my answer. Thanks for all the suggestions and help!

0 Kudos
Message 8 of 8
(4,654 Views)