# Interpolation doesn't reproduce the character of original curve

2 views (last 30 days)

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

### Accepted Answer

Matt J
on 10 Dec 2021

Edited: Matt J
on 10 Dec 2021

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')

### More Answers (1)

Matt J
on 10 Dec 2021

Edited: Matt J
on 10 Dec 2021

I don't know how you are plotting, but it should look like this:

plot(x,v,xq,vq,'x--')

##### 7 Comments

Matt J
on 10 Dec 2021

### See Also

### Community Treasure Hunt

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

Start Hunting!