View
10
Download
0
Category
Tags:
Preview:
Citation preview
GENERATION OF BASIC SIGNALS
Expt.No.1
Date:
AIM To write a MATLAB program to generate various type of signals.
ALGORITHM
1. Start the program.
2. Clear the command window using ‘clc’ function.
3. Create the array of time sequence by assigning values of‘t’.
4. Get the input value using the ‘input’ function for generating various sequences.
5. Provide matrix values by giving zero and ones values in ‘y’.
6. Using ‘subplot’ function plot the graph and use ‘stem’ to obtain discrete sequence.
7. Label in the X and Y axis using ‘label’ function.
8. End the program.
1
PROGRAM
clc; clear all; close all;
%Generation of cosine sequencet1=0:.01:pi;y1=cos(2*pi*t1);figure(1);subplot(3,2,1);plot(t1,y1);ylabel('Amplitude---->');xlabel('(a)n---->');
%Generation of sine sequencey2=sin(2*pi*t1);subplot(3,2,2);plot(t1,y2);ylabel('Amplitude---->');xlabel('(b)n---->');
%Generation of exponential sequencen2=input('Enter the length of exponential sequence: ');t3=0:n2;a=input('Enter the value: ');y3=exp(a*t3);subplot(3,2,3);stem(t3,y3);ylabel('Amplitude---->');xlabel('(c)n---->');
2
%Generation of unit impulse signalt4=-2:1:2;y4=[zeros(1,2),ones(1,1),zeros(1,2)];subplot(3,2,4);stem(t4,y4);ylabel('Amplitude---->');xlabel('(d)n---->');
%Generation of unit step sequencen5=input('Enter the N value for unit step sequence: ');t5=0:1:n5-1;y5=ones(1,n5);subplot(3,2,5);stem(t5,y5);ylabel('Amplitude---->');xlabel('(e)n---->');
%Generation of unit ramp sequencen6=input('Enter the length of ramp sequence: ');t6=0:n6;subplot(3,2,6);stem(t6,t6);ylabel('Amplitude---->');xlabel('(f)n---->');
3
OUTPUT
Enter the length of exponential sequence: 4Enter the value: 4Enter the N value for unit step sequence: 6Enter the length of ramp sequence: 5
4
RESULT
Thus the MATLAB program for generation of various types of signals was written and the waveforms were obtained.
5
LINEAR CONVOLUTION OF TWO GIVEN SEQUENCES
Expt No.2
Date:
AIM To write a MATLAB program to perform linear convolution.
ALGORITHM
1. Start the program.2. Clear the command window using ‘clc’ function.3. Get the two signals x(n) and h(n) using ‘input’ function. 4. The signal is convolved using ‘conv’ function and is denoted
as y(n), given by the formula y(n) = x(n) * h(n).
5. Plot them using ‘stem’ function.6. End the program.
6
PROGRAM
%linear convolution of two sequencesclc; clear all; close all;x=input('Enter the first sequence : ');h=input('Enter the second sequence : ');y=conv(x,h);figure;subplot(3,2,1);stem(x);ylabel('Amplitude---->');xlabel('(a)n---->');subplot(3,2,2);stem(h);ylabel('Amplitude---->');xlabel('(b)n---->');subplot(3,2,3);stem(y);ylabel('Amplitude---->');xlabel('(c)n---->');disp('The resultant signal is:');y
7
OUTPUT
Enter the first sequence : [1 2 3 4 5]Enter the second sequence : [1 1 -2]The resultant signal is:
y =
1 3 3 3 3 -3 -10
8
RESULT Thus the matlab program to perform linear convolution was written and the output was obtained.
9
CIRCULAR CONVOLUTION OF TWO GIVEN SEQUENCES
Expt No.3
Date:
AIM To write a MATLAB program to perform circular convolution.
ALGORITHM
1. Start the program.2. Clear the command window using ‘clc’ function.3. Get the two signals x(n) and h(n) using ‘input’ function. 4. The convoluted signal is denoted as y(n) and given by the formula:
y(n) = x(n) h(n)
5. Plot them using ‘stem’ function.6.End the program.
10
N
PROGRAM
%circular convolution of two sequencesclc; clear all; close all;g=input('Enter the first sequence: ');h=input('Enter the second sequence: ');N1=length(g);N2=length(h);N=max(N1,N2);N3=N1-N2;%loop for generating equal lengthif(N3>=0) h=[h,zeros(1,N3)];else g=[g,zeros(1,-N3)];end%computation of circular convolutionfor n=1:N y(n)=0; for i=1:N j=n-i+1; if(j<=0) j=N+j; end y(n)=y(n)+g(i)*h(j); endendsubplot(3,2,1);stem(g);ylabel('Amplitude---->');xlabel('(a)n---->');subplot(3,2,2);stem(h);ylabel('Amplitude---->');xlabel('(b)n---->');subplot(3,2,3);stem(y);ylabel('Amplitude---->');xlabel('(c)n---->');disp('The resultant signal is; ');y
11
OUTPUT Enter the first sequence: [1 2 3 4 5]Enter the second sequence: [5 4 3 2 1]The resultant signal is; y = 45 40 40 45 55
Enter the first sequence: [1 2]Enter the second sequence: [2 3 4]The resultant signal is:y = 10 7 10
12
RESULT Thus the matlab program to perform circular convolution was written and the output was obtained.
13
DFT OF A GIVEN SEQUENCE USING FFT
Expt No.4
Date:
AIM To write a matlab program to perform DFT of a given sequence using FFT.
ALGORITHM
1. Start the program.2. Clear the command window using ‘clc’ function.3. Get the two signals x(n) and length of DFT to be performed using ‘input’ function.4. Calculate the DFT using given formula
y=fft(x,n).5. Plot them using ‘stem’ function. 6. End the program.
14
PROGRAM %fft of two sequencesclc; clear all; close all;x=input('Enter the sequence : ');n=input('Enter the n value : ');y=fft(x,n);figure;subplot(3,2,1);stem(x);ylabel('Amplitude---->');xlabel('(a)n---->');subplot(3,2,2);stem(real(y));ylabel('Amplitude---->');xlabel('(b)n---->');subplot(3,2,3);stem(imag(y));ylabel('Amplitude---->');xlabel('(c)n---->');disp('The resultant signal is:');y
15
OUTPUT Enter the sequence : [.5 0 .5 0 .5 0 .5 0]Enter the n value : 8The resultant signal is:y = 2 0 0 0 2 0 0 0
Enter the sequence : [1 2 3 4 4 3 2 1]Enter the n value : 8The resultant signal is:y = Columns 1 through 6 20.0000 -5.8284 - 2.4142i 0 -0.1716 - 0.4142i 0 -0.1716 + 0.4142i Columns 7 through 8 0 -5.8284 + 2.4142i
16
RESULT Thus the matlab program to perform DFT of a given sequence using FFT was written and the output was obtained.
17
IDFT OF A GIVEN SEQUENCE USING IFFT
Expt No.5
Date:
AIM To write a matlab program to perform IDFT of a given sequence using IFFT.
ALGORITHM
1. Start the program.2. Clear the command window using ‘clc’ function.3. Get the two signals x(n) and length of IDFT to be performed using ‘input’ function.4. Calculate the IDFT using given formula
y=ifft(x,n).5. Plot them using ‘stem’ function. 6. End the program.
18
PROGRAM %ifft of two sequencesclc; clear all; close all;x=input('Enter the sequence : ');n=input('Enter the n value : ');y=ifft(x,n);figure;subplot(3,2,1);stem(real(x));ylabel('Amplitude---->');xlabel('(a)n---->');subplot(3,2,2);stem(imag(x));ylabel('Amplitude---->');xlabel('(b)n---->');subplot(3,2,3);stem(y);ylabel('Amplitude---->');xlabel('(c)n---->');disp('The resultant signal is:');y
19
OUTPUT Enter the sequence : [20 -5.8284-2.4142j 0 -.1716-.4142j 0 -.1716+.4142j 0 -5.8284+2.4142j]Enter the n value : 8The resultant signal is:y = 1.0000 2.0000 3.0000 4.0000 4.0000 3.0000 2.0000 1.0000
Enter the sequence : [2 0 0 0 2 0 0 0]Enter the n value : 8The resultant signal is:y = 0.5000 0 0.5000 0 0.5000 0 0.5000 0
20
RESULT Thus the matlab program to perform IDFT of a given sequence using IFFT was written and the output was obtained.
21
DESIGN OF BUTTERWORTH LOW PASS IIR FILTER
Expt No.6
Date:
AIM To write a matlab program to design a Butterworth lowpass filter and to verify the output.
ALGORITHM
1. Start the program.2. Clear the command window using ‘clc’ function.3. Get the pass band and stop band ripples.4. Get the pass band and stop band frequencies.5. Get the sampling frequency.6. Calculate the order of filter.7. Calculate the transfer function of the filter using the co- efficients.8. Plot magnitude and phase responses. 9. End the program.
22
PROGRAM clc; close all;clear all;wp=input('Enter the passband frequency: ');ws=input('Enter the stopband frequency: ');rp=input('Enter the passband ripple : ');rs=input('Enter the passband ripple : ');fs=input('Enter the sampling frequency: ');w1=2*wp/fs;w2=2*ws/fs;[N,wn]=buttord(w1,w2,rp,rs);[b,a]=butter(N,wn);w=0:.01:pi;[h,omega]=freqz(b,a,w);gain=20*log10(abs(h));subplot(2,2,1);plot(omega/pi,gain);grid;xlabel('\omega/pi,gain');ylabel('Gain in db---->');title('IIR Butterworth LPF: gain');subplot(2,2,2);an=angle(h);plot(omega/pi,an);grid;xlabel('\omega/pi,gain');ylabel('Phase in radians---->');title('IIR Butterworth LPF: phase');disp('Order of the filter is: ');N
23
OUTPUT Enter the passband frequency: 20Enter the stopband frequency: 30Enter the passband ripple : 2Enter the passband ripple : 10Enter the sampling frequency: 100Order of the filter is:
N =
3
24
RESULT Thus the matlab program to design a Butterworth lowpass filter was written and the output was obtained.
25
DESIGN OF BUTTERWORTH HIGH PASS IIR FILTER
Expt No.7
Date:
AIM To write a matlab program to design a Butterworth highpass filter and to verify the output.
ALGORITHM
1. Start the program.2. Clear the command window using ‘clc’ function.3. Get the pass band and stop band ripples.4. Get the pass band and stop band frequencies.5. Get the sampling frequency.6. Calculate the order of filter.7. Calculate the transfer function of the filter using the co- efficients.8. Plot magnitude and phase responses. 9. End the program.
26
PROGRAM clc; close all;clear all;wp=input('Enter the passband frequency: ');ws=input('Enter the stopband frequency: ');rp=input('Enter the passband ripple : ');rs=input('Enter the passband ripple : ');fs=input('Enter the sampling frequency: ');w1=2*wp/fs;w2=2*ws/fs;[N,wn]=buttord(w1,w2,rp,rs);[b,a]=butter(N,wn,'high');w=0:.01:pi;[h,omega]=freqz(b,a,w);gain=20*log10(abs(h));subplot(2,2,1);plot(omega/pi,gain);grid;xlabel('\omega/pi,gain');ylabel('Gain in db---->');title('IIR Butterworth HPF: gain');subplot(2,2,2);an=angle(h);plot(omega/pi,an);grid;xlabel('\omega/pi,gain');ylabel('Phase in radians---->');title('IIR Butterworth HPF: phase');disp('Order of the filter is: ');N
27
OUTPUT Enter the passband frequency: 30Enter the stopband frequency: 20Enter the passband ripple : 2Enter the passband ripple : 10Enter the sampling frequency: 100Order of the filter is:
N =
3
28
RESULT Thus the matlab program to design a Butterworth highpass filter was written and the output was obtained.
29
DESIGN OF BUTTERWORTH BAND PASS IIR FILTER
Expt No.8
Date:
AIM To write a matlab program to design a Butterworth bandpass filter and to verify the output.
ALGORITHM
1. Start the program.2. Clear the command window using ‘clc’ function.3. Get the pass band and stop band ripples.4. Get the pass band and stop band frequencies.5. Get the sampling frequency.6. Calculate the order of filter.7. Calculate the transfer function of the filter using the co- efficients.8. Plot magnitude and phase responses. 9. End the program.
30
PROGRAM clc; close all;clear all;wp=input('Enter the passband frequency: ');ws=input('Enter the stopband frequency: ');rp=input('Enter the passband ripple : ');rs=input('Enter the passband ripple : ');fs=input('Enter the sampling frequency: ');w1=2*wp/fs;w2=2*ws/fs;[N,wn]=buttord(w1,w2,rp,rs);[b,a]=butter(N,wn);w=0:.01:pi;[h,omega]=freqz(b,a,w);gain=20*log10(abs(h));subplot(2,2,1);plot(omega/pi,gain);grid;xlabel('\omega/pi,gain');ylabel('Gain in db---->');title('IIR Butterworth BPF: gain');subplot(2,2,2);an=angle(h);plot(omega/pi,an);grid;xlabel('\omega/pi,gain');ylabel('Phase in radians---->');title('IIR Butterworth BPF: phase');disp('Order of the filter is: ');N
31
OUTPUT Enter the passband frequency: [40 65]Enter the stopband frequency: [30 75]Enter the passband ripple : 1Enter the passband ripple : 40Enter the sampling frequency: 200Order of the filter is:
N =
8
32
RESULT Thus the matlab program to design a Butterworth bandpass filter was written and the output was obtained.
33
DESIGN OF BUTTERWORTH BAND STOP IIR FILTER
Expt No.9
Date:
AIM To write a matlab program to design a Butterworth bandstop filter and to verify the output.
ALGORITHM
1. Start the program.2. Clear the command window using ‘clc’ function.3. Get the pass band and stop band ripples.4. Get the pass band and stop band frequencies.5. Get the sampling frequency.6. Calculate the order of filter.7. Calculate the transfer function of the filter using the co- efficients.8. Plot magnitude and phase responses. 9. End the program.
34
PROGRAM clc; close all;clear all;wp=input('Enter the passband frequency: ');ws=input('Enter the stopband frequency: ');rp=input('Enter the passband ripple : ');rs=input('Enter the passband ripple : ');fs=input('Enter the sampling frequency: ');w1=2*wp/fs;w2=2*ws/fs;[N,wn]=buttord(w1,w2,rp,rs);[b,a]=butter(N,wn,'stop');w=0:.01:pi;[h,omega]=freqz(b,a,w);gain=20*log10(abs(h));subplot(2,2,1);plot(omega/pi,gain);grid;xlabel('\omega/pi,gain');ylabel('Gain in db---->');title('IIR Butterworth BSF: gain');subplot(2,2,2);an=angle(h);plot(omega/pi,an);grid;xlabel('\omega/pi,gain');ylabel('Phase in radians---->');title('IIR Butterworth BSF: phase');disp('Order of the filter is: ');N
35
OUTPUT Enter the passband frequency: [30 75]Enter the stopband frequency: [45 65]Enter the passband ripple : 1 Enter the passband ripple : 40Enter the sampling frequency: 200Order of the filter is:
N =
7
36
RESULT Thus the matlab program to design a Butterworth bandstop filter was written and the output was obtained.
37
DESIGN OF CHEBYSHEV-I LOW PASS IIR FILTER
Expt No.10
Date:
AIM To write a matlab program to design a chebyshev-I lowpass filter and to verify the output.
ALGORITHM
1. Start the program.2. Clear the command window using ‘clc’ function.3. Get the pass band and stop band ripples.4. Get the pass band and stop band frequencies.5. Get the sampling frequency.6. Calculate the order of filter.7. Calculate the transfer function of the filter using the co- efficients.8. Plot magnitude and phase responses. 9. End the program.
38
PROGRAM clc; close all;clear all;wp=input('Enter the passband frequency: ');ws=input('Enter the stopband frequency: ');rp=input('Enter the passband ripple : ');rs=input('Enter the stopband ripple : ');fs=input('Enter the sampling frequency: ');w1=2*wp/fs;w2=2*ws/fs;[N,wn]=cheb1ord(w1,w2,rp,rs);[b,a]=cheby1(N,rp,wn);w=0:.01:pi;[h,omega]=freqz(b,a,w);gain=20*log10(abs(h));subplot(2,2,1);plot(omega/pi,gain);grid;xlabel('\omega/pi,gain');ylabel('Gain in db---->');title('IIR Chebyshev-I LPF: gain');subplot(2,2,2);an=angle(h);plot(omega/pi,an);grid;xlabel('\omega/pi,gain');ylabel('Phase in radians---->');title('IIR Chebyshev LPF: phase');disp('Order of the filter is: ');N
39
OUTPUT Enter the passband frequency: 30Enter the stopband frequency: 80Enter the passband ripple : 20Enter the stopband ripple : 300Enter the sampling frequency: 200Order of the filter is:
N =
14
40
RESULT Thus the matlab program to design a chbyshev-I lowpass filter was written and the output was obtained.
41
DESIGN OF CHEBYSHEV-II LOW PASS IIR FILTER
Expt No.11
Date:
AIM To write a matlab program to design a chebyshev-II lowpass filter and to verify the output.
ALGORITHM
1. Start the program.2. Clear the command window using ‘clc’ function.3. Get the pass band and stop band ripples.4. Get the pass band and stop band frequencies.5. Get the sampling frequency.6. Calculate the order of filter.7. Calculate the transfer function of the filter using the co- efficients.8. Plot magnitude and phase responses. 9. End the program.
42
PROGRAM clc;close all;clear all;wp=input('Enter the passband frequency: ');ws=input('Enter the stopband frequency: ');rp=input('Enter the passband ripple : ');rs=input('Enter the stopband ripple : ');fs=input('Enter the sampling frequency: ');w1=2*wp/fs;w2=2*ws/fs;[N,wn]=cheb2ord(w1,w2,rp,rs);[b,a]=cheby2(N,rp,wn);w=0:.01:pi;[h,omega]=freqz(b,a,w);gain=20*log10(abs(h));subplot(2,2,1);plot(omega/pi,gain);grid;xlabel('\omega/pi,gain');ylabel('Gain in db---->');title('IIR Chebyshev LPF: gain');subplot(2,2,2);an=angle(h);plot(omega/pi,an);grid;xlabel('\omega/pi,gain');ylabel('Phase in radians---->');title('IIR Chebyshev LPF: phase');disp('Order of the filter is: ');N
43
OUTPUT Enter the passband frequency: 90Enter the stopband frequency: 60Enter the passband ripple : 100Enter the passband ripple : 250Enter the sampling frequency: 200Order of the filter is:
N =
9
44
RESULT Thus the matlab program to design a chebyshev-II lowpass filter was written and the output was obtained.
45
DESIGN OF FIR FILTER USING RECTANGULAR WINDOW
Expt No. 12
Date:
AIM To write a matlab program to design a FIR filter using rectangular window and to verify the output.
ALGORITHM
1. Start the program.2. Clear the command window using ‘clc’ function.3. Get the pass band and stop band ripples.4. Get the pass band and stop band frequencies.5. Get the sampling frequency.6. Calculate the order of filter.7. Calculate the transfer function of the filter using the co- efficients.8. Plot magnitude and phase responses. 9. End the program.
46
PROGRAM
%rectangular window computationclc; close all;clear all;rp=input('Enter the passband ripple: ');rs=input('Enter the stopband ripple: ');fp=input('Enter the passband frequency: ');fs=input('Enter the stopband frequency: ');f=input('Enter the sampling frequency: ');wp=2*fp/f;ws=2*fs/f;num=-20*log10(sqrt(rp*rs))-13;dem=14.6*(fs-fp)/f;n=ceil(num/dem);n1=n+1;if(rem(n,2)~=0) n1=n; n=n-1;enddisp('The order is:');ny=rectwin(n1);
%lowpass filterb=fir1(n,wp,y);[h,om]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,1);plot(om/pi,m);ylabel('Gain in dB---->');xlabel('Frequency in rad/sec---->');
%highpass filterb=fir1(n,wp,'high',y);[h,om]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,2);
47
plot(om/pi,m);ylabel('Gain in dB---->');xlabel('Frequency in rad/sec---->');%bandpass filterwn=[wp ws];b=fir1(n,wn,y);[h,om]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(om/pi,m);ylabel('Gain in dB---->');xlabel('Frequency in rad/sec---->');
%bandstop filterb=fir1(n,wn,'stop',y);[h,om]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,4);plot(om/pi,m);ylabel('Gain in dB---->');xlabel('Frequency in rad/sec---->');
48
OUTPUT
Enter the passband ripple: .05Enter the stopband ripple: .03Enter the passband frequency: 1300Enter the stopband frequency: 1600Enter the sampling frequency: 7400The order is:
n =
26
49
RESULT
50
Thus the matlab program to design a FIR filter using rectangular window was written and the output was verified.
DESIGN OF FIR FILTER USING HAMMING WINDOW
Expt No. 13
Date:
AIM To write a matlab program to design a FIR filter using hamming window and to verify the output.
ALGORITHM
1. Start the program.2. Clear the command window using ‘clc’ function.3. Get the pass band and stop band ripples.4. Get the pass band and stop band frequencies.5. Get the sampling frequency.6. Calculate the order of filter.7. Calculate the transfer function of the filter using the co- efficients.8. Plot magnitude and phase responses. 9. End the program.
51
PROGRAM
%hamming window computationclc; close all;clear all;rp=input('Enter the passband ripple: ');rs=input('Enter the stopband ripple: ');fp=input('Enter the passband frequency: ');fs=input('Enter the stopband frequency: ');f=input('Enter the sampling frequency: ');wp=2*fp/f;ws=2*fs/f;num=-20*log10(sqrt(rp*rs))-13;dem=14.6*(fs-fp)/f;n=ceil(num/dem);n1=n+1;if(rem(n,2)~=0) n1=n; n=n-1;enddisp('The order is:');ny=hamming(n1);
%lowpass filterb=fir1(n,wp,y);[h,om]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,1);plot(om/pi,m);ylabel('Gain in dB---->');xlabel('Frequency in rad/sec---->');
%highpass filterb=fir1(n,wp,'high',y);
52
[h,om]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,2);plot(om/pi,m);ylabel('Gain in dB---->');xlabel('Frequency in rad/sec---->');%bandpass filterwn=[wp ws];b=fir1(n,wn,y);[h,om]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(om/pi,m);ylabel('Gain in dB---->');xlabel('Frequency in rad/sec---->');
%bandstop filterb=fir1(n,wn,'stop',y);[h,om]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,4);plot(om/pi,m);ylabel('Gain in dB---->');xlabel('Frequency in rad/sec---->');
53
OUTPUT
Enter the passband ripple: .05Enter the stopband ripple: .03Enter the passband frequency: 1300Enter the stopband frequency: 1600Enter the sampling frequency: 7400The order is:
n =
26
54
55
RESULT Thus the matlab program to design a FIR filter using hamming window was written and the output was verified.
DESIGN OF FIR FILTER USING KAISER WINDOW
Expt No. 14
Date:
AIM To write a matlab program to design a FIR filter using Kaiser window and to verify the output.
ALGORITHM
1. Start the program.2. Clear the command window using ‘clc’ function.3. Get the pass band and stop band ripples.4. Get the pass band and stop band frequencies.5. Get the sampling frequency.6. Calculate the order of filter.7. Calculate the transfer function of the filter using the co- efficients.8. Plot magnitude and phase responses. 9. End the program.
56
PROGRAM
%kaiser window computation
clc; close all;clear all;rp=input('Enter the passband ripple: ');rs=input('Enter the stopband ripple: ');fp=input('Enter the passband frequency: ');fs=input('Enter the stopband frequency: ');f=input('Enter the sampling frequency: ');beta=input('Enter the beta value: ');wp=2*fp/f;ws=2*fs/f;num=-20*log10(sqrt(rp*rs))-13;dem=14.6*(fs-fp)/f;n=ceil(num/dem);n1=n+1;if(rem(n,2)~=0) n1=n; n=n-1;enddisp('The order is:');ny=kaiser(n1,beta);
%lowpass filterb=fir1(n,wp,y);[h,om]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,1);plot(om/pi,m);ylabel('Gain in dB---->');xlabel('Frequency in rad/sec---->');
57
%highpass filterb=fir1(n,wp,'high',y);[h,om]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,2);plot(om/pi,m);
ylabel('Gain in dB---->');xlabel('Frequency in rad/sec---->');
%bandpass filterwn=[wp ws];b=fir1(n,wn,y);[h,om]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(om/pi,m);ylabel('Gain in dB---->');xlabel('Frequency in rad/sec---->');
%bandstop filterb=fir1(n,wn,'stop',y);[h,om]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,4);plot(om/pi,m);ylabel('Gain in dB---->');xlabel('Frequency in rad/sec---->');
58
OUTPUT
Enter the passband ripple: .05Enter the stopband ripple: .03Enter the passband frequency: 1300Enter the stopband frequency: 1600Enter the sampling frequency: 7400Enter the beta value: 7The order is:
n =
26
59
60
RESULT Thus the matlab program to design a FIR filter using Kaiser window was written and the output was verified.
DESIGN OF IIR FILTER USING BILINEAR TRANSFORMATION
Expt No. 15
Date:
AIM To write a matlab program to design an IIR filter using bilinear transformation technique and to verify the output.
ALGORITHM
1. Start the program.2. Clear the command window using ‘clc’ function.3. Get the input values of input poles and zeroes.4. Get the input value of sampling interval.5. Compute the [z,p] values using bilinear transformation technique.6. Print the output. 7. End the program.
61
PROGRAM
%bilinear transformclc;close all;clear all;pin=input('Enter the poles: ');zin=input('Enter the zeros: ');t=input('Enter the sampling interval:');[z,p]=bilinear(zin,pin,1/t)
62
OUTPUT
Enter the poles: [1 3 2]Enter the zeros: 2Enter the sampling interval:1
z =
0.1667 0.3333 0.1667
p =
1.0000 -0.3333 0.0000
63
RESULT
Thus the matlab program for design of IIR filter using bilinear transformation was written and the output was verified.
DESIGN OF IIR FILTER USING IMPULSE INVARIANCE
Expt No. 16
Date:
AIM To write a matlab program to design an IIR filter using impulse invariance technique and to verify the output.
ALGORITHM
1. Start the program.2. Clear the command window using ‘clc’ function.3. Get the input values of input poles and zeroes.4. Get the input value of sampling interval.5. Compute the [z,p] values using impulse invariance technique.6. Print the output. 7. End the program.
64
PROGRAM
%impulse invariance clc;close all;clear all;pin=input('Enter the poles: ');zin=input('Enter the zeros: ');t=input('Enter the sampling interval:');[z,p]=impinvar(zin,pin,1/t)
65
OUTPUT
Enter the poles: [1 3 2]Enter the zeros: 2Enter the sampling interval:1
z =
0 0.4651
p =
1.0000 -0.5032 0.0498
66
RESULT Thus the matlab program for design of IIR filter using impulse
invariance was written and the output was verified.
67
Recommended