Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert measured data into equation

Status
Not open for further replies.

dreamer81

Electrical
Aug 1, 2005
6
Hi, i have some measured data, that when you plot them will result in a 3rd order polynomium.

Anyone know of a way to calculate the 3rd order coefficients???

 
Replies continue below

Recommended for you

You use any of a number of statistical analysis routines that can be found in Excel, Mathcad, Matlab, TKSolver, Mathematica, Calculation Center, SPSS, etc.

TTFN



 
I have to make the conversion in my .NET application :(
 
Then get a copy of Numerical Recipes and start reading

TTFN



 
A quick way in excel or MATLAB or C++ is to create a matrix of power of your x axis coordinates and then invert it. For instance, if your data is equally spaced at points x = 0.1, 1.1, 2.1, and 3.1 then you would make a matrix of x to the zero power, first power, second power and finally the third power.

X = 1 0.1 0.1^2 0.1^3
1 1.1 1.1^2 1.1^3
1 2.1 2.1^2 2.1^3
1 3.1 3.1^2 3.1^3

The inver X using excel or inv in MATLAB or 1 / X in the TNT (Template Numerical Toolkit) available for free on the net for C++.

if your data is
y = 5.3 6.3 7.3 8.3

Then you would multiply y as a column vector by inv(x) to get your coefficients.

c = y * X^-1

This is only OK for "good" data with less than 10 points. If you have more points you should use a numerically better solution as suggested by
IRstuff
as in Numerical Recipes
or the TNT library
or the MATLAB backslash or QR functions. You would also want to augment them as explained in the literature.

 
The technique you want is called least squares system identification. Visigoth has the right idea on how you set up the array phi array. The least squares system identication requires matrix mulitplication and inversion. As stated above, this is easy with math cad. Excel has a built in function called LINEST. A matrix class for C++ also makes this function easy.
 
If you have an Excel, plot your points as X-Y scatter graph.With you mouse pointer right click on a point on the graph and choose
Format Data Series
Custom.
You will get a line through the points.R-click on the line and you will get a form Add Trendline.
Under Type choose Polynomial, Order 3;
under Options choose Display Equation On Chart
and you'll get it!
If you want a differently formated result then right clickt he result, choose FormatData Labels and then choose one of the available formats (number, scientific..).
You can copy the result into a cell on a sheet but however the result is written as a string of chracters so you need some work to separate constants of the polynomial as individual values in particular cells.
m777182
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor