Interpolation doesn't reproduce the character of original curve

조회 수: 1 (최근 30일)
AR
AR 2021년 12월 10일
댓글: Matt J 2021년 12월 10일
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
John D'Errico
John D'Errico 2021년 12월 10일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2021년 12월 10일
편집: Matt J 2021년 12월 10일
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
The vector v is just a list of values. It doesn't have a unique domain x. If the goal is to compress the plot, you just need to redefine v's domain. It doesn't require interpolation,e.g.,
x=linspace(0,2*pi,100);
v=sin(x);
xc=linspace(0,pi,100);
plot(x,v,xc,v,'x'); legend('Original','Compressed')
  댓글 수: 5
Matt J
Matt J 2021년 12월 10일
Easier to do,
xq=linspace(min(xq), max(xq), numel(v));
plot(x,v,xq,v,'x')
AR
AR 2021년 12월 10일
This may be workable, but here we are coming up with a new xq and keeping v. In my case, I don't think I can change xq. I would need to keep xq and come up with a new v. Anyway, we have a workable solution one way or another.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt J
Matt J 2021년 12월 10일
편집: Matt J 2021년 12월 10일
I don't know how you are plotting, but it should look like this:
plot(x,v,xq,vq,'x--')
  댓글 수: 7
AR
AR 2021년 12월 10일
I would appreciate understanding what it does when the span of xq > the span of x. How does table lookup work here?
Matt J
Matt J 2021년 12월 10일
interp1 will need to extrapolate outside the range of x. It will do that according to the extrapolation settings that you give to interp1:

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by