Interpolate non-monotonic test data
Show older comments
Hello all,
I want to interpolate at specific values the curve in the picture attached (say every 0.01 in the x axis). Any idea how? The test data consists of a huge number of data points, so I want to clean them a bit.
Thanks

Accepted Answer
More Answers (1)
Image Analyst
on 7 Aug 2015
0 votes
Try interp1(). By the way, interpolation won't "clean" the data. Why do you think it will? It will just give you more points in between the noisy ones. Perhaps you meant "regress" instead of "interpolate"??? If you meant regress, see my attached demo on polyfit().
Please READ THIS and then attach your screenshot (which you forgot to attach), and original data file, and maybe some code to read in the data file.
3 Comments
Walter Roberson
on 17 Aug 2015
Maybe they want to do a spline smoothing? Or some kind of low-pass filtering?
Image Analyst
on 17 Aug 2015
I most certainly don't know everything about splines but I thought you give it training points, and it fits polynomials (like cubics) between them so that the slopes match at the training points. So if the original data is used as training points for the splines, then that noisy/erratic data is still in there. Sure you can interpolate points in between the noisy points, as my attached demo shows:

So, between the noisy data points it's smooth but the noisy data points are still there in the data.
Now maybe there's a different kind of spline that I need to learn about. That's quite possible as I know there are many flavors of splines and I'm just familiar with cubic splines.
For smoothing 1-D signals, I often use a Savitzky-Golay filter like I just did in this Answer: http://www.mathworks.com/matlabcentral/answers/234003-how-to-plot-a-histogram-with-distribution-fitting#answer_189490

Walter Roberson
on 17 Aug 2015
Categories
Find more on Smoothing 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!