Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

curve fitting

To start with: I have a large data set of points for a curve (on the order of 12000). The curve itself is a rather irradic signal. I am attempting to generate a polynomial fit (of any order) to this curve, but so far the resulting curves have been flat lines until the end when they would sweep away from the Axis.

I have tried to follow some of the points people have posted to similar questions but I really didn't understand the solutions.

I have attached both the data text file, and a bitmap of the curves: The top is the original curve, the middle is the "fitted" curve (polynomial of order 5) and the bottom curve is the difference between the original and the fitted.

I have looked into the NonLinearCurve fit function, but I am not su
re what the ModelFunctionCallback parameter is all about. It would seem that I need to create my own funtion of some sorts.

Thank you for any thoughts.
~Sinisa Stokic
Download All
0 Kudos
Message 1 of 2
(3,624 Views)
Sinisa,

To use the NonLinearFit function in the .NET version of Measurement Studio, you have to create a delegate function based on the ModelFunctionCallback outline. In other words, you would create a function like:

public delegate double MY_FUNCTION(double x, double[] coefficients)
{
//Set Y (Return Value) to something in relation to x and any number of coefficients, the example below is for y=ax^2+bx+c
return(coefficient[0]*x*x + coeffecient[1]*x + coeffecient[2]);
}
Then when you actually call the NonLinearFit function, you will pass MY_FUNCTION in the ModelFunctionCall parameter. The nubmer of coeffecients that you send to the NonLinearFit function should match the number that you have in your MY_FUNCTION. The algorithms within the functions wil
l then take it from there to create the best values of the coefficients to fit the curve. I hope this explains these functions a little more. If you have any other questions, feel free to post back. Have a good one.

Adam B.
Applications Engineer
National Instruments
Message 2 of 2
(3,624 Views)