Interpolation doesn't reproduce the character of original curve
Show older comments
Using the Matlab function notation for interp1: x, v, xq, and vq {vq = interp1(x, v, xq, 'method')}, I am trying to create a 1-d vector vq as a function of 1-d vector xq to recreate the shape of the curve v(x). I am trying to attach images that show the x & xq on one plot, and v & the resultant vq on another plot.
I have tried various 'methods', and none reproduces the original character of the curve v(x). I don't understand why and what I need to do (other than laborious self-computation) to get there. Appreciate pointers.


3 Comments
Matt J
on 10 Dec 2021
I am trying to attach images that show the x & xq on one plot, and v & the resultant vq on another plot.
Why attach images? Why not attach a .mat file with all the variables and Run your code for us.

That way we can not only see the result, but play with the data as well?
John D'Errico
on 10 Dec 2021
EXACTLY. Without your data, we cannot help you that much. A picture of your data might be interesting, but it does not tell us enough. Attach a .mat file to a comment, or to your original question by editting the question.
I will note that since xq is NOT monotonic, then I would expect vq to also not be monotonic.
Accepted Answer
More Answers (1)
I don't know how you are plotting, but it should look like this:
plot(x,v,xq,vq,'x--')
7 Comments
AR
on 10 Dec 2021
AR
on 10 Dec 2021
John D'Errico
on 10 Dec 2021
Edited: John D'Errico
on 10 Dec 2021
As I poiinted out in my comment to your question, if xq is not monotonic, then vq will also not be monotonic. But we really need to have your data to offer a good explanation. You do not need to post the code that produced it.
Perhaps I misunderstood how this works. I expected v to be scaled (compressed as it were in this case) and be reproduced over the new range xq.
You did misunderstand. Interpolation is like table lookup. It will evaluate v(x) at one or more xq, treating x as the domain of v. So if xq spans a particular interval a<=xq<=b, interp1 will evaluate v(xq) over that interval.
AR
on 10 Dec 2021
Matt J
on 10 Dec 2021
interp1 will need to extrapolate outside the range of x. It will do that according to the extrapolation settings that you give to interp1:
Categories
Find more on Interpolation 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!

