DTFT on for filter

2 次查看(过去 30 天)
Tu Nguyen
Tu Nguyen 2022-2-15
评论: Paul 2022-2-16
I need to find DTFT of h1 and h2 on MATLAB, but the graph and what I calculation is very different on h2. If anyone knows, please help me check
h1 = [.5 .5];
h2 = [0.5 -0.5];
omega = -4*pi:0.01:4*pi;
fz1 = freqz(h1,1,omega);
fz2 = freqz(h2,1,omega);
figure (7);
subplot(2,1,1);
plot(omega/pi, abs(fz1));
grid on
title('Magnitude response of h1[n]');
hold on
subplot(2,1,2);
plot(omega/pi,abs(fz2));
grid on
title('Magnitude response of h2[n]');
hold off

回答(1 个)

Paul
Paul 2022-2-16
What exactly is not matching for h2? Did you do something different for h1? Looks like freqz returns the DTFT of h2 as it should. Well, at least the magnitude, I didn't check the phase.
h1 = [.5 .5];
h2 = [0.5 -0.5];
omega = -4*pi:0.01:4*pi;
fz1 = freqz(h1,1,omega);
fz2 = freqz(h2,1,omega);
figure;
subplot(2,1,1);
plot(omega/pi, abs(fz1));
grid on
title('Magnitude response of h1[n]');
subplot(2,1,2);
hold on
plot(omega/pi,abs(fz2));
grid on
title('Magnitude response of h2[n]');
plot(omega/pi,abs(h2(1)+h2(2)*exp(-1j*omega)),'ro','MarkerIndices',1:20:numel(omega))
hold off
  2 个评论
Tu Nguyen
Tu Nguyen 2022-2-16
Because when I check the point of h2 at pi/2, it should result in imaginbary number, nut on the graph it return 0.717. That's why I think I did something wrong on the h2 DTFT
Paul
Paul 2022-2-16
The DTFT of h2 at omega = pi/2 is
h2 = [0.5 -0.5];
fz2 = h2(1) + h2(2)*exp(-1j*pi/2)
fz2 = 0.5000 + 0.5000i
Its magnitude, which is what is being plotted using the abs() function, is
abs(fz2)
ans = 0.7071
which is indeed 0.7071, and is shown on the plot above at the x-axis value of 1/2 (because the independent variable for those plots is omega/pi). Feel free to show the manual calculations if they are yielding a different result.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by