DTFT on for filter
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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 个评论
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)
Its magnitude, which is what is being plotted using the abs() function, is
abs(fz2)
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 Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!