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?
我想插入一个长度为3的向量y1来得到长度为6的向量y2。我应该使用函数interp1或resample吗?
ex. y1=[1 2 3]; y2=[1 2 3 4 5 6 ];
恩。 y1 = [1 2 3]; y2 = [1 2 3 4 5 6];
resample(y1,length(y2),length(y1))
重新取样(Y1,长度(Y2),长度(Y1))
1 个解决方案
#1
2
Use interp1
.
使用interp1。
Ex: You have a sinusoidal signal sampled every pi/4.
例如:每个pi / 4都有一个正弦信号采样。
x = 0:pi/4:2*pi;
v = sin(x);
Now to want a finer sampling xq
(every pi/16):
现在想要更精细的采样xq(每个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
其中vq1是一个向量,其值从vto插值以满足新的采样xq
PD: You can also pass as a parameter which type of interpolation you want: 'linear', 'nearest', 'cubic', etc...
PD:您还可以将所需的插值类型作为参数传递:'linear','nearest','cubic'等...
#1
2
Use interp1
.
使用interp1。
Ex: You have a sinusoidal signal sampled every pi/4.
例如:每个pi / 4都有一个正弦信号采样。
x = 0:pi/4:2*pi;
v = sin(x);
Now to want a finer sampling xq
(every pi/16):
现在想要更精细的采样xq(每个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
其中vq1是一个向量,其值从vto插值以满足新的采样xq
PD: You can also pass as a parameter which type of interpolation you want: 'linear', 'nearest', 'cubic', etc...
PD:您还可以将所需的插值类型作为参数传递:'linear','nearest','cubic'等...