如何在 Matlab 中生成信号的低频版本?
通过正弦输入,我尝试修改它的频率,切割频谱中的一些较低频率,将主频率移向零。由于信号没有进行 fftshifted,我尝试通过消除 fft 向量开头和结尾的一些样本来做到这一点:
interval = 1;
samplingFrequency = 44100;
signalFrequency = 440;
sampleDuration = 1 / samplingFrequency;
timespan = 1 : sampleDuration : (1 + interval);
original = sin(2 * pi * signalFrequency * timespan);
fourierTransform = fft(original);
frequencyCut = 10; %% Hertz
frequencyCut = floor(frequencyCut * (length(pattern) / samplingFrequency) / 4); %% Samples
maxFrequency = length(fourierTransform) - (2 * frequencyCut);
signal = ifft(fourierTransform(frequencyCut + 1:maxFrequency), 'symmetric');
但它没有按预期工作。我还尝试去除频谱的中心部分,但它也使用了更高频率的正弦波。
怎样做才正确呢?
With a sine input, I tried to modify it's frequency cutting some lower frequencies in the spectrum, shifting the main frequency towards zero. As the signal is not fftshifted I tried to do that by eliminating some samples at the begin and at the end of the fft vector:
interval = 1;
samplingFrequency = 44100;
signalFrequency = 440;
sampleDuration = 1 / samplingFrequency;
timespan = 1 : sampleDuration : (1 + interval);
original = sin(2 * pi * signalFrequency * timespan);
fourierTransform = fft(original);
frequencyCut = 10; %% Hertz
frequencyCut = floor(frequencyCut * (length(pattern) / samplingFrequency) / 4); %% Samples
maxFrequency = length(fourierTransform) - (2 * frequencyCut);
signal = ifft(fourierTransform(frequencyCut + 1:maxFrequency), 'symmetric');
But it didn't work as expected. I also tried to remove the center part of the spectrum, but it wielded a higher frequency sine wave too.
How to make it right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@las3rjock:
它更像是对信号本身进行下采样,而不是 FFT。
查看downsample。
或者您可以创建一个 timeseries 对象,并使用它重新采样重新采样方法。
编辑:
类似的示例:)
@las3rjock:
its more like downsampling the signal itself, not the FFT..
Take a look at downsample.
Or you could create a timeseries object, and resample it using the resample method.
EDIT:
a similar example :)
将频谱下采样
n
的一种粗略方法是,为了使其成为原始时间轴上的低频信号,您需要将此向量补零至原始长度在正极和负极两端。使用 fftshift 可以使这变得更加简单:
要恢复降档信号,请在应用逆变换之前将 fftshift 返回:
编辑:这是一个完整的脚本,它生成一个比较原始信号和降档信号的图:
< a href="http://img5.imageshack.us/img5/5426/downshift.png" rel="nofollow noreferrer">原始信号和降档信号图 http://img5.imageshack.us/img5/5426/downshift .png
A crude way to downsample your spectrum by a factor of
n
would beFor this to be a lower-frequency signal on your original time axis, you will need to zero-pad this vector up to the original length on both the positive and negative ends. This will be made much simpler using fftshift:
To recover the downshifted signal, you fftshift back before applying the inverse transform:
EDIT: Here is a complete script which generates a plot comparing the original and downshifted signal:
Plot of original and downshifted signals http://img5.imageshack.us/img5/5426/downshift.png