DSP Lab Programs1
DSP Lab Programs1
DSP Lab Programs1
2.Type the program and save with file name and with the extension .dpj
3. Click on assembly and select ‘Add File To Project’/Selec t your program in the place where you saved and open.
4. Click on the cmd file and select ‘Add File To Project’/my project-> click the file ‘Micro 5416’ and open.
11. Enter the input and click the ‘reset’ key on the kit and verify the output.
;******************************************************************
;Input:
;Data Memory:
; A000h 0004h
; A001h 0004h
;Output:
;Data Memory:
; A002h 0008h
2.SUBTRACTION
;******************************************************************
INP1 .SET 0H
INP2 .SET 1H
OUT .SET 2H
.mmregs
.text
START:
LD #140H,DP
RSBX CPL
NOP
NOP
NOP
NOP
LD INP1,A
SUB INP2,A
STL A,OUT
HLT: B HLT
;******************************************************************
;Input:
;Data Memory:
; A000h 0004h
; A001h 0002h
;Output:
;Data Memory:
; A002h 0002h
3.DIVISION
;******************************************************************
DIVID .SET 0H
DIVIS .SET 1H
OUT .SET 2H
.mmregs
.text
START:
STM #140H,ST0
RSBX CPL
RSBX FRCT
NOP
NOP
NOP
NOP
LD DIVID,A ;dividend to acc
RPT #0FH
SUBC DIVIS,A ;A / DIVIS -> A
STL A,OUT ;result in 9002h
HLT: B HLT
.END
;******************************************************************
;INPUT
;DATA MEMORY
; A000H 000AH
; A001H 0002H
;OUTPUT
; A002H 0005H
4.CIRCULAR CONVOLUTION FOR FOUR INPUTS
;******************************************************************
.mmregs
.text
START:
STM #0140H,ST0
RSBX CPL
RSBX FRCT
NOP
NOP
NOP
NOP
STM #0A020H,AR2
RPT #4H
ST #0H,*AR2+
STM #0A000H,AR0 ;x1(n)
STM #0A010H,AR1 ;x2(n)
STM #0A020H,AR2
STM #0A030H,AR3 ;output y(n)
STM #3H,AR4 ;counter for finding y(1) to y(n)
CALL ROT1 ;180 degree rotate for y(0)
CALL CONV ;routine for convolution
NEXTY:CALL ROT2 ;routine for 90 degree rotation
CALL CONV
BANZ NEXTY,*AR4-
HLT: B HLT
;routine for 180 degree rotation
ROT1:
STM #0A011H,AR0 ;exchange x1(1) and x1(3)
STM #0A013H,AR1
LD *AR0,A
LD *AR1,B
STL A,*AR1
STL B,*AR0
RET
;routine for 90 degree rotation
ROT2:
STM #0A013H,AR0
STM #0A012H,AR1
LD *AR0,A ;store x2(3) to acc(a)temporarily
STM #2H,BRC
RPTB ROT ;x2(2)->x2(3)
LD *AR1-,B ;x2(1)->x2(2)
ROT:
STL B,*AR0- ;x2(0)->x2(1)
STM #0A010H,AR0 ;acc(a)->x2(0)
STL A,*AR0
STM #0H,BRC
RET
CONV:
STM #0A000H,AR0
STM #0A010H,AR1
LD #0H,A
STM #3H,BRC
RPTB CON
LD *AR0+,T
;multiply and add loop
CON:
MAC *AR1+,A
STL A,*AR3+ ;store the result in AR3 and increment AR3
RET
;******************************************************************
;INPUT X1(n) DATA MEMORY
; 0A000 0002
; 0A001 0001
; 0A002 0002
; 0A003 0001
;******************************************************************
5.LOW-PASS FILTER
;******************************************************************
;Filter type : FIR-LPF
;Window type : Rectangular window
;Sampling frequency : 41khz
;Cut-off frequency : 4khz
;No. of taps : 52
.mmregs
.text
START:
STM #01h,ST0
RSBX CPL
RSBX FRCT
NOP
NOP
STM #150H,AR1
LD #0H,A
RPT #34H
STL A,*AR1+
LOOP:
PORTR 06,0
CHK_BUSY:
; PORTR 07,0
; BITF 0,#20H
; BC CHK_BUSY,TC
PORTR 04,0
LD 0,A
AND #0FFFH,A
XOR #0800H,A
SUB #800H,A
STM #150H,AR1
STL A,*AR1
STM #183H,AR2
LD #0H,A
RPT #33H
MACD *AR2-,TABLE,A
STH A,1,0H
LD 0H,A
ADD #800H,A
STL A,1H
PORTW 1H,04H
B LOOP
;fs = 41khz ; fc = 4khz ; N = 52
TABLE:
.word 01FH
.word 010EH
.word 01ABH
.word 01B4H
.word 0117H
.word 0H
.word 0FECDH
.word 0FDEEH
.word 0FDC2H
.word 0FE6EH
.word 0FFCDH
.word 016FH
.word 02C0H
.word 0333H
.word 0274H
.word 097H
.word 0FE19H
.word 0FBCBH
.word 0FA9BH
.word 0FB53H
.word 0FE50H
.word 0362H
.word 09C5H
.word 01048H
.word 01599H
.word 01895H
.word 01895H
.word 01599H
.word 01048H
.word 09C5H
.word 0362H
.word 0FE50H
.word 0FB53H
.word 0FA9BH
.word 0FBCBH
.word 0FE19H
.word 097H
.word 0274H
.word 0333H
.word 02C0H
.word 016FH
.word 0FFCDH
.word 0FE6EH
.word 0FDC2H
.word 0FDEEH
.word 0FECDH
.word 0H
.word 0117H
.word 01B4H
.word 01ABH
.word 010EH
.word 01FH
6.HIGH PASS FIR FILTER
;******************************************************************
;Sampling freq : 43khz
;Cut-off freq : 2khz
;N : 52
;Filter type : High pass filter
;Window type : Rectangular
;Program Description:
;1. Make all the x(n) zero initially
;2. Read the data from the adc.
;3. Store the adc data in x(0)
;4. Make the pointer to point the x(n_end)
;5. Perform the convolution of x(n) and the coefficients h(n) using
; MACD instruction.
;6. Send the convolution output to the dac
;7. Repeat from step 2.
.mmregs
.text
START:
STM #01h,ST0 ;intialize the data page pointer
RSBX CPL ;Make the processor to work using DP
RSBX FRCT ;reset the fractional mode bit
NOP
NOP
;*****loop to make all x(n) zero initially*****
STM #150H,AR1 ;initialize ar1 to point to x(n)
LD #0H,A ;make acc zero
RPT #34H
STL A,*AR1+ ;make all x(n) zero
;*****to read the adc data and store it in x(0)*****
LOOP:
PORTR 06,0 ;start of conversion
CHK_BUSY:
; PORTR 07,0 ;check for busy
; BITF 0,#20H
; BC CHK_BUSY,TC
PORTR 04,0 ;read the adc data
LD 0,A
AND #0FFFH,A ;AND adc data with 0fffh for 12 bit adc
XOR #0800H,A ;recorrect the 2's complement adc data
SUB #800H,A ;remove the dc shift
STM #150H,AR1 ;initialize ar1 with x(0)
STL A,*AR1 ;store adc data in x(0)
STM #183H,AR2 ;initialize ar2 with x(n_end)
;*****start of convolution*****
LD #0H,A ;sum is 0 initially
RPT #33H
MACD *AR2-,TABLE,A ;convolution process
STH A,1,0H
LD 0H,A
ADD #800H,A ;add the dc shift to the convolution output
STL A,1H
PORTW 1H,04H ;send the output to the dac
B LOOP
TABLE:
.word 0FCEFH
.word 62H
.word 0FD50H
.word 14AH
.word 0FE1BH
.word 28FH
.word 0FF11H
.word 3E5H
.word 0FFD1H
.word 4ECH
.word 0FFF5H
.word 54FH
.word 0FF28H
.word 4DAH
.word 0FD38H
.word 398H
.word 0FA2EH
.word 1DDH
.word 0F627H
.word 55H
.word 0F131H
.word 4BH
.word 0EA6DH
.word 568H
.word 0D950H
.word 459EH
.word 459EH
.word 0D950H
.word 568H
.word 0EA6DH
.word 4BH
.word 0F131H
.word 55H
.word 0F627H
.word 1DDH
.word 0FA2EH
.word 398H
.word 0FD38H
.word 4DAH
.word 0FF28H
.word 54FH
.word 0FFF5H
.word 4ECH
.word 0FFD1H
.word 3E5H
.word 0FF11H
.word 28FH
.word 0FE1BH
.word 14AH
.word 0FD50H
.word 62H
.word 0FCEFH
7.BAND PASS FIR FILTER
;******************************************************************
;Sampling freq : 43khz
;Cut-off freq1 : 2khz
;Cut-off freq2 : 4khz
;N : 52
;Filter type : Band pass filter
;Window type : Rectangular
;Program Description:
;1. Make all the x(n) zero initially
;2. Read the data from the adc.
;3. Store the adc data in x(0)
;4. Make the pointer to point the x(n_end)
;5. Perform the convolution of x(n) and the coefficients h(n) using
; MACD instruction.
;6. Send the convolution output to the dac
;7. Repeat from step 2.
.mmregs
.text
START:
STM #01h,ST0 ;intialize the data page pointer
RSBX CPL ;Make the processor to work using DP
RSBX FRCT ;reset the fractional mode bit
NOP
NOP
;*****loop to make all x(n) zero initially*****
STM #150H,AR1 ;initialize ar1 to point to x(n)
LD #0H,A ;make acc zero
RPT #34H
STL A,*AR1+ ;make all x(n) zero
;*****to read the adc data and store it in x(0)*****
LOOP:
PORTR 06,0 ;start of conversion
CHK_BUSY:
;PORTR 07,0 ;check for busy
; BITF 0,#20H
; BC CHK_BUSY,TC
PORTR 04,0 ;read the adc data
LD 0,A
AND #0FFFH,A ;AND adc data with 0fffh for 12 bit adc
XOR #0800H,A ;recorrect the 2's complement adc data
SUB #800H,A ;remove the dc shift
STM #150H,AR1 ;initialize ar1 with x(0)
STL A,*AR1 ;store adc data in x(0)
STM #183H,AR2 ;initialize ar2 with x(n_end)
;*****start of convolution*****
LD #0H,A ;sum is 0 initially
RPT #33H
MACD *AR2-,TABLE,A ;convolution process
STH A,1,0H
LD 0H,A
ADD #800H,A ;add the dc shift to the convolution output
STL A,1H
PORTW 1H,04H ;send the output to the dac
B LOOP
TABLE:
.word 208H
.word 257H
.word 218H
.word 143H
.word 0H
.word 0FE9EH
.word 0FD7AH
.word 0FCE7H
.word 0FD08H
.word 0FDD1H
.word 0FEECH
.word 0FFE4H
.word 3DH
.word 0FFA1H
.word 0FDFCH
.word 0FB8FH
.word 0F8ECH
.word 0F6D4H
.word 0F608H
.word 0F713H
.word 0FA21H
.word 0FEE6H
.word 4A7H
.word 0A60H
.word 0EF8H
.word 1187H
.word 1187H
.word 0EF8H
.word 0A60H
.word 4A7H
.word 0FEE6H
.word 0FA21H
.word 0F713H
.word 0F608H
.word 0F6D4H
.word 0F8ECH
.word 0FB8FH
.word 0FDFCH
.word 0FFA1H
.word 3DH
.word 0FFE4H
.word 0FEECH
.word 0FDD1H
.word 0FD08H
.word 0FCE7H
.word 0FD7AH
.word 0FE9EH
.word 0H
.word 143H
.word 218H
.word 257H
.word 208H
;Program Description:
;1. Make all the x(n) zero initially
;2. Read the data from the adc.
;3. Store the adc data in x(0)
;4. Make the pointer to point the x(n_end)
;5. Perform the convolution of x(n) and the coefficients h(n) using
; MACD instruction.
;6. Send the convolution output to the dac
;7. Repeat from step 2.
.mmregs
.text
START:
STM #01h,ST0 ;intialize the data page pointer
RSBX CPL ;Make the processor to work using DP
RSBX FRCT ;reset the fractional mode bit
NOP
NOP
;*****loop to make all x(n) zero initially*****
STM #150H,AR1 ;initialize ar1 to point to x(n)
LD #0H,A ;make acc zero
RPT #34H
STL A,*AR1+ ;make all x(n) zero
;*****to read the adc data and store it in x(0)*****
LOOP:
PORTR 06,0 ;start of conversion
CHK_BUSY:
; PORTR 07,0 ;check for busy
; BITF 0,#20H
; BC CHK_BUSY,TC
PORTR 04,0 ;read the adc data
LD 0,A
AND #0FFFH,A ;AND adc data with 0fffh for 12 bit adc
XOR #0800H,A ;recorrect the 2's complement adc data
SUB #800H,A ;remove the dc shift
STM #150H,AR1 ;initialize ar1 with x(0)
STL A,*AR1 ;store adc data in x(0)
STM #183H,AR2 ;initialize ar2 with x(n_end)
;*****start of convolution*****
LD #0H,A ;sum is 0 initially
RPT #33H
MACD *AR2-,TABLE,A ;convolution process
STH A,1,0H
LD 0H,A
ADD #800H,A ;add the dc shift to the convolution output
STL A,1H
PORTW 1H,04H ;send the output to the dac
B LOOP
TABLE:
.word 0FEB9H
.word 14EH
.word 0FDA1H
.word 155H
.word 0FE1BH
.word 282H
.word 0FEAFH
.word 2ACH
.word 0FD35H
.word 8DH
.word 0F9D9H
.word 0FE07H
.word 0F7CCH
.word 0FEE2H
.word 0FA2FH
.word 4BAH
.word 1AH
.word 25CH
.word 420H
.word 1008H
.word 89H
.word 0D61H
.word 0F3F2H
.word 0AF9H
.word 0DB7EH
.word 045DFH
.word 045DFH
.word 0DB7EH
.word 0AF9H
.word 0F3F2H
.word 0D61H
.word 89H
.word 1008H
.word 420H
.word 25CH
.word 1AH
.word 4BAH
.word 0FA2FH
.word 0FEE2H
.word 0F7CCH
.word 0FE07H
.word 0F9D9H
.word 8DH
.word 0FD35H
.word 2ACH
.word 0FEAFH
.word 282H
.word 0FE1BH
.word 155H
.word 0FDA1H
.word 14EH
.word 0FEB9H
1.UPSAMPLING
n=0:1:5;
x=[1 2 3 4 5]
y=upsample(x,2);
disp(y);
subplot(2,2,1);
plot(y);
title('up sampling');
subplot(2,2,2);
y=downsample(x,2);
disp(y);
plot(y);
title('down sample');
2.POLYPHASE DECOMPOSITION
%Analog signal
t=-0.005:0.00005:0.005;
xa=exp(-1000*abs(t));
%Discrete time signal
Fs=input('Enter the sampling frequency(Fs)= ');
Ts=1/Fs;
n=-25:1:25;
xn=exp(-1000*abs(n*Ts));
%Discrete time fourier transform
N=500;
k=0:1:N;
w=(2*pi*k/N);
X=xn*exp(-1i*n'*w);
X=abs(X);
%omega range from -Wmax to Wmax
W=[-fliplr(w),w(2:N+1)];
%X over -Wmax to Wmax interval
X=[fliplr(X),X(2:N+1)];
subplot(2,1,1);
plot(t*1000,xa,'k');
grid;
hold on;
stem(n*Ts*1000,xn,'k');
xlabel('time in sec');
ylabel('x(n)');
title('discrete time signal');
gtext('Ts=1msec');
hold off;
3.CALCULATING IMPULSE AND STEP RESPONSES FOR A GIVEN DIFFERENCE EQUATION AND
ALSO PLOTTING FREQUENCY RESPONSE
a=[1 -0.4];
b=[0.5 1.5];
c=dimpulse(b,a);
d=dstep(b,a);
disp('The impulse response is');c
disp('The step response is');d
subplot(3,1,1);
stem(c);
subplot(3,1,2);
stem(d);
w=-pi:0.01:pi;
h=freqz(b,a,w);
m=20*log10(abs(h));
subplot(3,1,3);
plot(w/pi,m);
IIR FILTER PROGRAMS
1.DIGITAL LOWPASS BUTTERWORTH FILTER USING BILINEAR
clc;
close all;
clear all;
wp=input('Digital passband freq in rad/sec: ');
ws=input('Digital stopband freq in rad/sec: ');
gp=input('Passband gain: ');
gs=input('Stopband gain: ');
T=input('Sampling interval: ');
fs=1/T % Sampling freq
ap=-20*log10(gp) % Passbad ripple or attenuation Alpha_p in db
as=-20*log10(gs) % Stopband attenutaion Alpha_s in db
omp=(2/T)*tan(wp/2) % Analog passband freq in rad/sec
oms=(2/T)*tan(ws/2) % Analog stopband freq in rad/sec
[N,wc]=buttord(omp,oms,ap,as ,'s') % order & cutoff freq
[b,a]=butter(N,wc,'s') ;
HS=tf(b,a) % LPF transfer function H(S)
[num,den]=bilinear(b,a,1/T) ;
HZ=tf(num,den,T) % Digital transfer function H(Z)
freqz(num,den);
ANS:
Digital passband freq in rad/sec: 0.35*pi
Digital stopband freq in rad/sec: 0.7*pi
Passband gain: 0.6
Stopband gain: 0.1
Sampling interval: 0.1
fs = 10
ap = 4.4370
as = 20
omp = 12.2560
oms = 39.2522
N= 2
wc = 12.4439
Transfer function:
154.8
--------------------
s^2 + 17.6 s + 154.8
Transfer function:
0.1708 z^2 + 0.3415 z + 0.1708
------------------------------
z^2 - 0.5407 z + 0.2237
Sampling time: 0.1
2.DIGITAL HIGHPASS BUTTERWORTH FILTER USING BILINEAR
clc;
close all;
clear all;
wp=input('Digital passband freq in rad/sec: ');
ws=input('Digital stopband freq in rad/sec: ');
gp=input('Passband gain: ');
gs=input('Stopband gain: ');
T=input('Sampling interval: ');
fs=1/T % Sampling freq
ap=-20*log10(gp) % Passbad ripple or attenuation Alpha_p in db
as=-20*log10(gs) % Stopband attenutaion Alpha_s in db
omp=(2/T)*tan(wp/2) % Analog passband freq in rad/sec
oms=(2/T)*tan(ws/2) % Analog stopband freq in rad/sec
[N,wc]=buttord(omp,oms,ap,as ,'s') % order & cutoff freq
[b,a]=butter(N,wc,’high’,'s') ;
HS=tf(b,a) % LPF transfer function H(S)
[num,den]=bilinear(b,a,1/T) ;
HZ=tf(num,den,T) % Digital transfer function H(Z)
freqz(num,den);
ANS
Digital passband freq in rad/sec: 0.35*pi
Digital stopband freq in rad/sec: 0.7*pi
Passband gain: 0.6
Stopband gain: 0.1
Sampling interval: 0.1
fs = 10
ap = 4.4370
as = 20
omp = 12.2560
oms = 39.2522
N= 2
wc = 12.4439
Transfer function:
s^2
--------------------
s^2 + 17.6 s + 154.8
Transfer function:
0.4411 z^2 - 0.8822 z + 0.4411
------------------------------
z^2 - 0.5407 z + 0.2237
Sampling time: 0.1
3.DIGITAL BANDPASS BUTTERWORTH FILTER USING BILINEAR
clc;
close all;
clear all;
wp=input('Digital passband freq in rad/sec: ');
ws=input('Digital stopband freq in rad/sec: ');
gp=input('Passband gain: ');
gs=input('Stopband gain: ');
T=input('Sampling interval: ');
fs=1/T % Sampling freq
ap=-20*log10(gp) % Passbad ripple or attenuation Alpha_p in db
as=-20*log10(gs) % Stopband attenutaion Alpha_s in db
omp=(2/T)*tan(wp/2) % Analog passband freq in rad/sec
oms=(2/T)*tan(ws/2) % Analog stopband freq in rad/sec
[N,wc]=buttord(omp,oms,ap,as ,'s') % order & cutoff freq
[b,a]=butter(N,wc,’bandpass’,'s') ;
HS=tf(b,a) % LPF transfer function H(S)
[num,den]=bilinear(b,a,1/T) ;
HZ=tf(num,den,T) % Digital transfer function H(Z)
freqz(num,den);
ANS
Transfer function:
0.1053 z^4 - 1.242e-015 z^3 - 0.2107 z^2 - 7.567e-016 z + 0.1053
----------------------------------------------------------------
z^4 + 1.388e-015 z^3 + 0.8958 z^2 + 7.216e-016 z + 0.3172
clc;
close all;
clear all;
wp=input('Digital passband freq in rad/sec: ');
ws=input('Digital stopband freq in rad/sec: ');
gp=input('Passband gain: ');
gs=input('Stopband gain: ');
T=input('Sampling interval: ');
fs=1/T % Sampling freq
ap=-20*log10(gp) % Passbad ripple or attenuation Alpha_p in db
as=-20*log10(gs) % Stopband attenutaion Alpha_s in db
omp=wp/T % Analog passband freq in rad/sec
oms=ws/T % Analog stopband freq in rad/sec
[N,wc]=buttord(omp,oms,ap,as ,'s') % order & cutoff freq
[b,a]=butter(N,wc,'s') ;
HS=tf(b,a) % LPF transfer function H(S)
[num,den]=impinvar(b,a,1/T) ;
HZ=tf(num,den,T) % Digital transfer function H(Z)
freqz(num,den);
ANS
Digital passband freq in rad/sec: 0.3*pi
Digital stopband freq in rad/sec: 0.75*pi
Passband gain: 0.707
Stopband gain: .2
Sampling interval: 1
fs = 1
ap = 3.0116
as = 13.9794
omp = 0.9425
oms = 2.3562
N= 2
wc = 1.0645
Transfer function:
1.133
---------------------
s^2 + 1.505 s + 1.133
Transfer function:
0.4848 z
-----------------------
z^2 - 0.6876 z + 0.2219
Sampling time: 1
5.DIGITAL LOWPASS CHEBYSHEV FILTER USING BILINEAR
clc;
close all;
clear all;
ANS
Digital passband freq in rad/sec: .2*pi
Digital stopband freq in rad/sec: .32*pi
Passband gain: .8
Stopband gain: .2
Sampling interval: 1
fs = 1
ap = 1.9382
as = 13.9794
omp = 0.6498
oms = 1.0995
N= 3
wc = 0.6498
Transfer function:
0.3333
----------------------------------
s^3 + 0.7489 s^2 + 1.03 s + 0.3333
Transfer function:
0.09147
-------------------------------------
s^3 + 0.4867 s^2 + 0.4351 s + 0.09147
Transfer function:
0.008386 z^3 + 0.02516 z^2 + 0.02516 z + 0.008386
-------------------------------------------------
z^3 - 2.274 z^2 + 1.967 z - 0.6263
Sampling time: 1
clc;
close all;
clear all;
fc=150;
fs=1300;
T=1/fs;
wc=(2*pi*fc)/fs;
N=input('enter the order of the filter');
fc=300;
fs=2000;
n = input('order: ');
n=mod(n,2)+n;
wc=2*fc/fs;
figure(1);
b=fir1(n,wc,hamming(n+1));
freqz(b,1,512)
xlabel('freq in hz' );ylabel('gain in db');title('freq response of lowpass
filter');
figure(2);
b=fir1(n,wc,'high',hamming(n+1));
freqz(b,1,512)
xlabel('freq in hz' );ylabel('gain in db');title('freq response of lowpass
filter');
fc=300;
fs=2000;
t=0:1/fs:0.2;
n = input('order: ');
n=mod(n,2)+n;
wc=2*fc/fs;
figure(1);
b=fir1(n,wc,blackman(n+1));
freqz(b,1,512)
xlabel('freq in hz' );ylabel('gain in db');title('freq response of lowpass
filter');
figure(2);
b=fir1(n,wc,'high',blackman(n+1));
freqz(b,1,512)
xlabel('freq in hz' );ylabel('gain in db');title('freq response of highpass
filter');
fc1=100;
fc2=450;
fs=1000;
n = input('order: ');
n=mod(n,2)+n;
wc1=2*fc1/fs;
wc2=2*fc2/fs;
wn=[wc1 wc2 ];
b=fir1(n,wn,'bandpass',boxcar(n+1));
freqz(b,1,512)
xlabel('freq in hz' );ylabel('gain in db');title('freq response of lowpass
filter');
clc;
close all;
clear all;
fc1=200;
fc2=450;
fs=1000;
n = input('order: ');
n=mod(n,2)+n;
wc1=2*fc1/fs;
wc2=2*fc2/fs;
wn=[wc1 wc2 ];
figure(1);
b=fir1(n,wn,'stop',boxcar(n+1));
freqz(b,1,512)
xlabel('freq in hz' );ylabel('gain in db');title('freq response of lowpass
filter');
figure(2);
b=fir1(n,wn,'stop',hanning(n+1));
freqz(b,1,512)
xlabel('freq in hz' );ylabel('gain in db');title('freq response of lowpass
filter');