Just create a new file with extension .m and paste the code below in that .m file. Then Run it.
clear all;
clc;
%starting of hamming
wc=.5*pi;
N=input('Enter the number of points : ');
subplot(6,1,1)
plot(hamming(N));grid;
ylabel('<-Magnitude->');
xlabel('<--Time-->');
h=freqz(b,1,w);
subplot(6,1,2)
plot(w/pi,abs(h));grid;
ylabel('<-Magnitude->');
xlabel('<--Normalized Frequency-->');
%starting of hanning
wc=.5*pi;
subplot(6,1,3)
plot(hanning(N));grid;
ylabel('<-Magnitude->');
xlabel('<--Time-->');
b=fir1(N,wc/pi,hanning(N+1));
w=0:.01:pi;
h=freqz(b,1,w);
subplot(6,1,4)
plot(w/pi,abs(h));grid;
ylabel('<-Magnitude->');
xlabel('<--Normalized Frequency-->');
%starting of rectangular
wc=.5*pi;
subplot(6,1,5)
plot(boxcar(N));grid;
ylabel('<-Magnitude->');
xlabel('<--Time-->');
b=fir1(N,wc/pi,boxcar(N+1));
w=0:.01:pi;
h=freqz(b,1,w);
subplot(6,1,6)
plot(w/pi,abs(h));grid;
ylabel('<-Magnitude->');
xlabel('<--Normalized Frequency-->');
No comments:
Post a Comment