04-25-2007 08:33 AM
Dear CVI developers
Please find enclosed an attempt of curvefitting that does not give the expected result.
I've noticed in the samples provided by CVI8.1 that the Xarray always is an array containing 1.0 2.0 ..... until the number of points required.
I'm trying to curve fit on a data set of real values on both X and Y. The data set represents "total efficiency of a pump (Y data) versus the load pressure it was subjected to (X data).
For info the data set represents a cycle of :
ramp up (20x5=100 samples, hold period (5x5=25) and ramp down (20x5=100). Numbers refers to 20 sec x 5Hz sampling.
I assume the main problem is lack of understaning of coef's values and the mathematics involved, but I still hope for support. Best regards Per Borgvad
04-25-2007 05:07 PM
Dear PerBorgvad,
I cannot test your complete example since I haven't cvi 8 installed here so I cannot open your UIR, but looking at your sample project I noticed that inside FitCurveProcedure you are retrieving from 2 fields on the screen the same coefficient for the non linear curve to pass to NonLinearFitWithMaxIters function:
GetCtrlVal (mainpnl, MAINPNL_IDEALPAR1, &coefs[0]);
GetCtrlVal (mainpnl, MAINPNL_IDEALPAR2, &coefs[0]);
It is possible that this is the reason of the abnormal behaviour you are observing.
But a more general question is: are you sure that you do need a non linear algorithm to fit your data? I modified your project adding a simple polinomial interpolation to your data, both handling up and down ramps in separate ways and considering your whole data arrays in a sngle pass, and it seems to me that fitted curve is a reasonable fitting of your original data. I am attaching the modified project inc ase you can consider this simpler approach to your problem.