DTFT on for filter

조회 수: 6 (최근 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