如何使用 Octave 对信号进行下采样?

How do I downsample a signal using Octave?

我一直在尝试对信号进行下采样,但不确定是否有正确的命令?你能给我一个简短的解释正确的命令吗?

w=13=will.y.w=12=w w=10=sh w=11=sh

根据您要实现的目标,downsample 就足够了。

示例代码:

pkg load signal % To download the signal package
x = cos(1:1000); % Create a signal
y = downsample(x, 2);

但是,它不会应用低通滤波器,因此它会在您的信号上引入不需要的混叠效应。就像命令 help downsample 说的那样:

For most signals you will want to use decimate instead since it prefilters the high frequency components of the signal and avoids aliasing effects.


现在如果你想下采样 应用低通滤波器,你想使用 decimate 但它只适用于整数因子的下采样,例如,从 96kHz 到 48kHz,您将抽取 2 倍。从 help decimate

Note that Q must be an integer for this rate change method.

示例代码:

pkg load signal % To download the signal package
x = cos(1:1000); % Create a signal
y = decimate(x, 2);

最后,如果你想按有理数进行下采样,例如从 96kHz 到 64kHz 的 2/3 倍,你将需要 resample,就像其他用户建议的那样。

pkg load signal % To download the signal package
x = cos(1:1000); % Create a signal
y = resample(x, 2, 3);

请注意,您仍然可以使用 resample 按整数因子进行下采样,例如 y = resample(x, 1, 2); 但它比 decimate 慢。