What are the formulas used behind the in-built function, "interp1"
Show older comments
Basically in MATLAB, I can perform interpolation using the in-built command "interp1". Regardless of how many samples I have in my SignalX initially, I can interpolate it and make SignalX consist of 40 samples after using the command "interp".
So for example,
SignalX = [6 7 14 30 80 147 155 170 150 11 24 112 81 91 92]; 13 samples
and after interpolation,
SignalX = [6.5493 6.0820 6.0190 6.2813 6.7896 7.8833 10.5123 14.0000 18.3584 24.5474 33.6856 50.8722 72.7026 97.8516 128.7401 147.0000 150.7079 152.9526 156.6432 163.8043 169.4981 168.5142 161.4505 150.0000 100.8972 31.0796 11.2489 14.6683 21.2734 40.9356 86.1473 112.0000 102.1914 85.8438 81.4048 85.7727 90.3963 91.4119 91.8434 92.000] 40 samples
Currently, I am trying to implement interpolation using Arduino but I can't find any step-by-step workings/formula that has been used to calculate the values of the new 40 samples. Therefore, I'm posting this to see if anyone have any idea of what is being done (calculation) behind the command 'interp1' so that i can actually re-write them in terms of C/C++ to use it in Arduino.
Sorry if my explanation above is poor,
Thank you
4 Comments
Rik
on 25 Feb 2018
In the doc it says you can generate C/C++ code with Matlab Coder. I don't know if that helps you.
Stephen23
on 25 Feb 2018
"What are the formulas used behind the in-built function interp1 ?"
This depends entirely on which interpolation method you are using, which you have not told us.
Soon Tat Quah
on 26 Feb 2018
Torsten
on 26 Feb 2018
Here is the article that describes the "pchip" method:
[1] Fritsch, F. N. and R. E. Carlson. "Monotone Piecewise Cubic Interpolation." SIAM Journal on Numerical Analysis. Vol. 17, 1980, pp.238–246.
Best wishes
Torsten.
Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!