DTFT on for filter

1 Ansicht (letzte 30 Tage)
Tu Nguyen
Tu Nguyen am 15 Feb. 2022
Kommentiert: Paul am 16 Feb. 2022
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

Antworten (1)

Paul
Paul am 16 Feb. 2022
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 Kommentare
Tu Nguyen
Tu Nguyen am 16 Feb. 2022
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 am 16 Feb. 2022
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.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by