Reputation: 153
i want to interpolate a vector y1 of length 3 to get a vector y2 of length 6.which of the functions interp1 or resample should i use?
ex. y1=[1 2 3]; y2=[1 2 3 4 5 6 ];
resample(y1,length(y2),length(y1))
Upvotes: 0
Views: 878
Reputation:
Use interp1
.
Ex: You have a sinusoidal signal sampled every pi/4.
x = 0:pi/4:2*pi;
v = sin(x);
Now to want a finer sampling xq
(every pi/16):
xq = 0:pi/16:2*pi;
The result will be:
vq1 = interp1(x,v,xq);
Where vq1
is a vector whose values are interpolated from v
to satisfy the new sampling xq
PD: You can also pass as a parameter which type of interpolation you want: 'linear', 'nearest', 'cubic', etc...
Upvotes: 2