【发布时间】:2015-10-26 04:55:08
【问题描述】:
我目前正在学习计算机科学,我有一个任务要解决我的实验室项目。我必须将输入的信号和系数从时域转移到频域,将它们加在一起并转移回时域。我的结果必须匹配过滤器函数输出。但是我似乎找不到这里做错了什么。当我通过 conj 函数添加两个频率时,我认为它有问题。不幸的是,我的老师和我的实验室主管都没有兴趣真正教任何东西,所以我必须自己找到答案。希望大家帮忙。
clc
clear
B = [0.2];
A = [1,-0.5];
xt = ones(1,20);
xt = padarray(xt,[0,100])
A1 = 1;
A2 = 1;
f1 = 1;
f2 = 25;
fs = 1000;
xd = fft(xt);
wd = freqz(B,A,length(xt));
y = filter(B,A,xt);
yd = conj((wd)').*xd;
yt = real(ifft(yd));
subplot(4,2,1);
plot(xt)
title('Input signal')
subplot(4,2,2);
plot(abs(xd))
title('Input in frequency domain')
subplot(4,2,4);
plot(abs(wd))
title('Coefficients in frequency domain')
subplot(4,2,7);
plot(y)
title('Output using FILTER function')
subplot(4,2,6);
plot(yd)
title('Adding input with coefficients in frequency domain')
subplot(4,2,8);
plot(yt)
title('Back to time domain using IFFT')
【问题讨论】:
-
我会将您的问题更改为“时域中的过滤与频域乘法不匹配。”
-
@BrianGoodwin 这是一个更好的标题。在阅读代码之前,我不明白这个问题的目的。