【问题标题】:Input & Coefficients from time domain to frequency, add them together and back to time domain从时域到频率的输入和系数,将它们加在一起并返回到时域
【发布时间】: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 这是一个更好的标题。在阅读代码之前,我不明白这个问题的目的。

标签: matlab signal-processing


【解决方案1】:

matlab 函数freqz() 可能有点误导。您的系数的“FFT”域需要以不同的方式生成。用下面的代码替换你的东西,它应该给你你想要的:

xt = xt.';
xd = fft(xt);
wd = freqz(B,A,length(xt),'whole');
y = filter(B,A,xt);
yd = wd.*xd;
yt = ifft(yd);

figure
plot(abs(xd))
hold on
plot(abs(wd))

figure
plot(y,'.k','markersize',20)
hold on
plot(yt,'k')
hold off

另外,关于带有复向量的 ' 运算符的注释:除非您使用 .' 运算符(例如,x = x.'),否则它将在取复共轭时转置向量,即 (1+1i).' = (1+1i)(1+1i)' = (1-1i)

【讨论】:

  • 谢谢!没想到回复这么快!!它真的有效:)
  • 哦。抱歉,我是新人 :) 已标记!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-16
  • 1970-01-01
  • 2023-02-25
  • 1970-01-01
  • 2021-08-04
  • 2014-10-24
相关资源
最近更新 更多