在 MATLAB 中对两个不同长度的数据集进行重采样
我有两个向量:长度为 927 的sensorA 和长度为1250 的sensorB。我想让它们具有相同的长度。 MATLAB 中的 resample() 函数在边缘处的噪声非常大,我至少需要在整个过程中具有相当好的精度。
我知道重采样可以通过插值来完成,但是如何以最有效的方式实现它。我需要尽可能均匀地拉伸 927 到 1250。
我想知道我是否可以做这样的事情:
- 我需要较短向量中的 333 个新样本。因此,对于每 3 个值,我在其间插入两个连续值的平均值(中点)。 =>插入了 309 个样本
- 对于剩余的样本,我每 38 个样本再次插入一次 (927/(333-309))
这有意义吗?我仍然无法获得精确的插值。还有其他我可以使用的功能吗? (除了 interp()
因为它需要整数重采样率?)
I have two vectors: sensorA of length 927 and sensorB of length 1250. I would like to make them of the same length. The resample() function in MATLAB is very noisy at the edges and I need atleast reasonably good accuracy throughout.
I understand that resampling can be done by interpolation, but how do I implement it in the most efficient way. I need to stretch 927 to 1250 as uniformly as possible.
I was wondering if I could do something like this:
- I need 333 new samples in the shorter vector. So for every 3 values, I insert the average (midpoint) of two consecutive values in between then. => 309 samples inserted
- For the remaining I insert again for every 38 samples (927/(333-309))
Does this make sense? I still won't be able to get an exact interpolation. Is there any other function that I could use? (besides interp()
because it requires an integral resampling rate?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从信号处理的角度来看,您不应该仅仅每 3 个值插入一个样本。这将是不均匀的拉伸,并会破坏你的信号。 resample 函数就是您想要的。尝试更改 n 和/或 beta 的参数。您可能需要按照此处所述填充信号 减少边缘效应。
From a signal-processing view, you should NOT just insert a sample every 3 values. That would be non-uniform stretching and would ruin your signal. The resample function is what you want. Try changing the parameters for n and/or beta. You may need to pad your signal as described here to reduce the edge effects.
对带限信号进行重采样与使用无限 Sinc 插值内核进行插值相同,并且非常接近使用精心选择的窗口进行的窗口 Sinc 插值。有关详细信息,请参阅斯坦福 CCRMA 网站。
Resampling a bandlimited signal is identical to interpolation using an infinite Sinc interpolation kernel, and pretty close to windowed Sinc interpolation with a well chosen window. See this Stanford CCRMA website for details.
要进行插值,请使用 interp1。就您的目的而言,这可能已经足够好了,但如上所述,重新采样是正确的做法。
To do interpolation, use interp1. For your purposes, this might be good enough, though, as stated above, resample is the correct thing to do.