Plotting a filter as a function of cyclic frequency using freqz()
이전 댓글 표시
Hello,
I'm trying to graph a moving average filter's magnitude response as a function of cyclic frequency. However, when I use freqz(), my plots do not look correct. Here's my code currently:
clear;close all;
fs = 200; %sampling frequency
Ts = 1/200; %sampling time
t = 0:Ts:1;
x = sin(2*pi*2*t) + sin(2*pi*10*t) + sin(2*pi*90*t); %signal
figure(1)
plot(t,x); %unfiltered signal
title('Signal with 2, 10, and 90 Hz');
xlabel('time (s)');
%Difference equation of Hanning Moving Average filter:
yn = zeros(size(t));
ind = 3:length(t);
yn(ind) = (0.25*x(ind)) + (0.5*x(ind-1)) + (0.25*x(ind-2));
%Attempt at creating the moving average equation.
figure(2)
plot(t,yn)
title("Hanning Moving Average")
%Me just plotting the filtered Hanning Moving Average plot with
%freqz():
figure(10)
freqz(yn)
Both the magnitude (dB) and the phase seem to show a lot of sound, but the plot of figure 2 does not. Any help will be appreciated.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


