'resample' 具有相同大小的信号

'resample' to have the same size of signals

我有 4 个(2 个速率和 2 个时间)信号,我需要均衡它们的大小。我先把它们剪掉,因为我也需要它。第一次和速率信号的大小是 3901,另一个是 830。但不仅仅是为了删除元素,我想保留曲线。我以为我需要插值并尝试“重新采样”,但它并不完美。看起来像照片。我应该如何改进我的代码?有什么想法吗?

 index=time >= 9.6 & tsyn <= 13.5; %time boundaries of first time signal
 time1=tsyn(index); %first time signal
 time_f=resample(time1,830,3901);
 Rate1=CLU_YR1(index)              %first rate signal
 Rate_f=resample(Rate1,830,3901);

 index2 = cm.Time.data >= 26.3 & cm.Time.data <= 30.45; %time boundaries of second time signal
 time2=cm.Time.data(index2)   %second time signal
 Rat2=cm.BodySensor_SC1_Omega_B_z.data*(-180/pi)        %second rate signal
 Rate_p=Rat2(index2)

我想你的曲线有些不合适是因为原始序列在向量的末尾不(接近)0。来自 matlab resample documentation:

When filtering, resample assumes that the input sequence, x, is zero before and after the samples it is given. Large deviations from zero at the endpoints of x can result in unexpected values for y.

最好的选择是什么取决于你下一步想做什么。如果你想要一个新的上采样版本(即长度为 3901 的两个信号),你可以查看 interp1,它支持多种不同的方法。如果您选择这样做,请记住 y(t) 中的值将根据您提供的 t 的值进行插值。由于您的时间数组似乎没有对齐(一个在 9.6 到 13 秒之间,另一个在 26 到 30 秒之间),您最好按照以下方式做一些事情:

y_new = interp1( linspace(1,100,830), rate_p, linspace(1,100,3901), 'linear');

时间数组也是如此。