## Interpolating automaticaly

29 posts / 0 new
Author
Message

Hi,
I have some tables, It's like this

0 511
1 518
2 533
5 580
10 664
15 753
21 861

I want to extract the algebra function from it(different systems with different current curves), Do you know some automatic ways? do you know a function in matlab or excel?

So for example it will give me a function and when I put the adc value I will get the interpolated current!

I love Digital
and you who involved in it!

The method to use depends on if the function is linear or have some more complicated shape.

For linear, Google "linear regression". The result will be a formula on the form

`y = k*x + m`

where the regression will supply the k and m values. You then insert your x value to interpolate (or, for the brave, extrapolate) the y value.

There exists different methods for estimating k and m. One often used, and relatively simple to calculate, is the method of "least squares". The method requires math operations like summing, squaring and taking the square root.

(This is high-school maths AFAIK.)

Is the analysis to be done on an AVR?
Is the interpolation to be done on an AVR?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Thanks,
The analysis would be on PC, but the function would be calculated on avr for interpolation, if the values are not linear what should I do to reach the best efficient math like function?

I love Digital
and you who involved in it!

That depends on the "form of the line". Exponential/logarithmic? Or some more complicated form.

For sure, even linear regression is of-course an approximation. Linear regression analysis can give you an estimate on how well a straight line fits your scattered points of data.

Quote:
The analysis would be on PC

Then your spreadsheet application will have linear regression built in. E.g. in OpenOffice/LibreOffice, look for the LINEST function.

There is also a LOGEST for non-linear functions.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Four legs good, two legs bad, three legs stable.

Great link thanks :)

Note that I want to extract the function,
For example I wanted to insert the table in the PC and PC would give me a function like y=0.5X + 1.34X^2 + 3X^3+0.3

Then I would insert numbers instead of x in my avr and calculate the y value!

I love Digital
and you who involved in it!

have you looked at John's link. It looks like they all there!

1. select polynomial
2. 3th order
etc
etc

Quote:

For example I wanted to insert the table in the PC and PC would give me a function like y=0.5X + 1.34X^2 + 3X^3+0.3

I use Microsoft Excel's curve fitting on a chart to get the equation and R value. You have to pick linear, etc.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

Quote:
have you looked at John's link. It looks like they all there!

It's seems it's down,I can not reach the link!

I love Digital
and you who involved in it!

Ali,

this site is available from here, so I think it is blocked by 'your' (being the iranian government I assume) firewall.

Take a look at XlXtrFun plugin for Excel. It's still the best tool for such things. It can assist you with choosing the minimal function degree needed with visual curve fitting based on entered data, and calculate polynomial coefficients for you. So after entering X-Y pairs data table of measured values, you get K0, K1, K2, K3... polynomial coefficients for Y = K0*X^0 + K1*X^1 + K2*X^2 + K3*X^3 + ... (depends on the function order you choose). For standard sensors medium accuracy is met with 3rd, and great accuracy with 4th or 5th order polynomial functions.

http://www.xlxtrfun.com/XlXtrFun...

## Attachment(s):

Zdravo Avro,

Evo mene u zemlji srbiji.

Quote:
Hi Avro,

Here's me u earth Serbia.

Huh?

Ross McKenzie, Melbourne Australia

I came across the " XlXtrFun plugin for Excel" some years ago. Thanks for reminding me. Their author has just turned 90 years old. Happy birthday Freeman Dyson!

http://en.wikipedia.org/wiki/Fre...

Ross McKenzie, Melbourne Australia

Hi,
I was looking to download the XlXtrFun plugin because i used to work with it on a previous PC. Somehow i cannot get passed the registration form, it gives me an error in return. Did somebody else had problems with that? I already send an email to their support group last night but without a response yet (i am maybe to hasty).
Thanks
Marjolein

Matlab Curve Fit tool, call "CFTool" from the matlab prompt to launch it.

I had been using a modified polyfit.bas program credited to William G. Hood from the June 1987 issue of Byte Magazine for many years until I lost the code some years ago. When I went searching for it, I found a similarily named program offered by Prof Robert Keen of Michigan State. It is not as elaborate as my modified version, but may be of help if you are interested. yell out and I will upload it if needed. It uses the method of least squares.

Cheers,

Ross

Ross McKenzie, Melbourne Australia

Dear avra
Thanks for the info,
But it seems I can not download the tool, no matter if I use my VPN
It says

Quote:
You don't have permission to access /cgi-bin/formmail/formmail.pl on this server.

I love Digital
and you who involved in it!

Quote:
.. it seems I can not download the tool...

I have just uploaded it to some free hosting service:
http://www.qfpost.com/file/d?g=y...

If you need Delphi code that can calculate polynomial coefficients based on entered data then tell me and I will upload that too.

Have fun!

btw. I really, really hate entering capture every time. Can't it just remember me for at least a few minutes?

Thanks avra, If you could upload the Delphi code too, it would be nice.

I love Digital
and you who involved in it!

Ali!

Is your example in the first post some real data?

If so, then you are quite close to linear.

(There is one drawback of the charting functionality in LibreOffice. It seems you can not have mixed types of data series. Below both your data and the interpolated series are lines. I would have liked your data to be points. It seems Excel wins out here. Hope the diagram is clear enough anyway.)

## Attachment(s):

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Quote:
Is your example in the first post some real data?
.Yes it's some real data

I love Digital
and you who involved in it!

A formula for "linear estimation" / interpolation of that data set is

`y = 16.875 * x + 501.25`

(My screen dump comes from a PC with Swedish locale - we use ',' as decimal delimiter.)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

If you have MATLAB it's easy. Just plot the data. In the plot window there's a menu item, "Tools" I think, that will let you fit a curve to the data. You can select anything from a straight line fit to 8th order or so.

Greg

Thanks

I love Digital
and you who involved in it!