【发布时间】:2018-05-27 03:45:35
【问题描述】:
我想将我的信号重新采样到新的时间。目前我的信号的采样时间是0.01s,我的信号和时间数组的大小是1*90001。
我正在尝试在 MATLAB 中使用 resample(x,p,q),但我有点困惑。
有人可以建议使用此功能的正确方法以及如何将我的数据重新采样为0.02s 而不是0.01s 的速率吗?
代码 - 这就是我尝试使用resample 的方式,以及示例数据。
t = [0:0.03:1];
x = sin(4*pi*t);
y = resample(x, 1, 2);
ty = resample(t,1,2);
figure (1);
stem(ty, y, 'r*');
hold on;
stem(t,x,'b')
hold off
更新代码:
t = [0 2 3 7 8 9 10 11 12 17 18 19 20 24 25 26 27 28 29 31 32 33 35 37 41 ];
A = [0 0 1 2 3 5.2 0 -1.4 0 2 2.7 2 2.3 6 7.3 0 0 -8.6 0 1 1 2.5 3 4.8 2];
plot(t,A)
% Tx = min(diff(t));
Tx = 1:0.1:25;
B = interp1(t,A,Tx); %re-make example data to have decimal points on the x-axis
y = resample(B, 2, 1);
T = 0.05;
Ty = T / (2 / 1);
ty = (0:length(y)-1)*Ty;
% A = interp1(t,ref,t2);
% A = ref;
figure
plot(Tx,B,'b')
hold on
plot(ty,y,'r')
plot(t,A,'g')
hold off
【问题讨论】:
标签: matlab signals signal-processing resampling