From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Nonlinear Curve Fit VI keeps all initial parameters

Sorry my bad...

Here is the model file.

0 Kudos
Message 11 of 23
(927 Views)

Well, the curve calculated from your initial estimates does not resembele th datya at all. You need to finid paramtere guesses that are more reasonable.

 

Here's a quick rewrite of the caller and model. I included plotting the curve for the initial estimates. You figure it out. 😉

0 Kudos
Message 12 of 23
(922 Views)

Thank you. It looks like the nonlinear curve fit vi is not capable of optimizing fit parameters for a complicated fit function like in my case. I could start with a fairly close initial parameter set that I got from Matlab optimization. With a fractional value change and inputing them to LabVIEW, the curve fitting result is either with fit parameters far away from the optimal or a failure that shows no optimal. Instead, if I change that to constrained nonlinear curve fit vi, the fitting result is very promising if I set the parameter boundary carefully. Have you seen such difference before? I would like to know if there is a better way to do this kind of curve fitting for nonlinear curve.

0 Kudos
Message 13 of 23
(892 Views)

Can you share the best fit parameters obtained using Matlab?

-Jim

0 Kudos
Message 14 of 23
(888 Views)

@stevensung wrote:

Thank you. It looks like the nonlinear curve fit vi is not capable of optimizing fit parameters for a complicated fit function like in my case.


I am using the nonlinear fit with models that are orders of magnitudes more complicated than that, so that's not the problem.

 

You model might be ill posed or poorly scaled and it might help to transform the data. Have you tried e.g. fitting the log of x and y and adjust the model accordingly.

 

Please show us what kind of initial parameters generate a curve that looks similar to the data.

 

Please show us your latest code. Are you sure that all parameters are uncorrelated?

0 Kudos
Message 15 of 23
(887 Views)

First of all, the model function is taken from my control engineering colleague so I have no doubt about its accuracy. They have perfomed quite lot of such nonlinear curve fitting other programs such as Matlab in the past and have not seen any issue. What I am tring to work on is to demonstrate the simiar capability of LabVIEW for such a curve fitting task. And I beleve with some tweaking we should be able to at least get the same result that people with other programs have reached so far. For this particular nonlinear curve fitting, with the raw data that I attached before, the optimal fitting parameter set obtained with Matlab is {A=5.0915, B=0.0000, C=1.000, p=1.9929, Min_Pickup=92}. And these parameters are not correlated as I know. I hope we could get to this with LabVIEW, with help from you guys.

 

Thanks.

0 Kudos
Message 16 of 23
(885 Views)

That problem is that with these initial paramters, the curve does not look at all like the data. Something is wrong in the model. Are you sure all the parts are correct? Can you link to a website that described the model in detail?

 

Once the model is corrected so the model calculation with these parameters looks like the data, we should be in business. Obviously, there is an error in the current model, that's all.

0 Kudos
Message 17 of 23
(881 Views)

Just playing around, using A/((x/I)^(p-C))+B instead gives a somewhat more reasonable curve (but C and p are of course 100% correlated now. Still, the fit succeeds!).

 

We really need a reliable reference for the correct model description to get it to work as expected.

 

 

0 Kudos
Message 18 of 23
(869 Views)

Hi Altenbach,

 

Thank you for your response in such a long chain. I modified my LV code to present the resulting fitting curves together with raw data and that with the initial fit parameters. As could be seen from the attached graph the initial fit parameters fit very well but the curve with output from the fitting function is far away from that of raw data. And that is with the Contrained Nonlinear Curve Fit VI. When I switch the called function to Nonlinear Curve Fit VI the situation becomes worse. If you try to play my LV code as attached you will see with that fit function the result is either worse or comes with a "No optimal value" error. And I believe that is what I have to figure out to solve this problem.

 

I hope this time I have provided enough information for you to help me out.

 

Please let me know if something is still missing.

 

0 Kudos
Message 19 of 23
(864 Views)

Please don't attach two different zip files with the same name.

 

EDIT: Ahh you corrected it!

0 Kudos
Message 20 of 23
(861 Views)