Professional Documents
Culture Documents
S.No Date Name of The Experiment NO Marks Signature
S.No Date Name of The Experiment NO Marks Signature
SOFTWARE REQUIRED:
System with MATLAB SOFTWARE
ALGORITHM:
1.Start the MATLAB program.
2.open New M-file .
3.Type the program.
4.Save the program in current directory.
5.Compile and run the program.
6.If any error occur in the program ,correct the error and run the program.
7.For the output see the command window or figure window.
8.Stop the program .
PROGRAM:
%program for generation of sinusodial signal
t=0:0.1:10;
y=sin(2*pi*t);
subplot(3,3,1);
plot(t,y,'k');
title('sinusodial signal');
xlabel('time');
ylabel('amplitude');
%program for exponential growing signal
t=0:0.1:3;
a=2;
y=exp(a*t);
subplot(3,3,2);
plot(t,y);
xlabel('time index');
ylabel('amplitude');
title('exponential growing signal');
%program for exponential decaying signal
t=0:1:8;
a=2;
y=exp(-a*t);
subplot(3,3,3);
plot(t,y);
xlabel('time index');
ylabel('amplitude');
title('exponential decaying signal');
%program for generation of unit impulse
t=-2:1:2;
y=[zeros(1,2),ones(1,1),zeros(1,2)];
subplot(3,3,4);
plot(t,y);
xlabel('time');
ylabel('amplitude');
title('unit impulse signal');
%program for generation of unit step signal
n=input('enter N values');
t=0:1:n-1;
y=ones(1,n);
subplot(3,3,5);
plot(t,y);
xlabel('time');
ylabel('amplitude');
title('unit step signal');
%program for generation of unit ramp signal
t=0:10;
subplot(3,3,6);
plot(t,t);
xlabel('time index');
ylabel('amplitude');
title('unit ramp signal');
OUTPUT:
RESULT:
EXP NO : 2
GENERATION OF DISCRETE TIME SIGNALS
DATE :
SOFTWARE REQUIRED:
System with MATLAB SOFTWARE
ALGORITHM:
1.Start the MATLAB program.
2.open New M-file .
3.Type the program.
4.Save the program in current directory.
5.Compile and run the program.
6.If any error occur in the program ,correct the error and run the program.
7.For the output see the command window or figure window.
8.Stop the program .
PROGRAM:
%program for generation of sinusodial signal
t=0:0.1:2;
y=sin(2*pi*t);
subplot(3,3,1);
stem(t,y,'k');
title('sinusodial signal');
xlabel('time');
ylabel('amplitude');
%program for exponential growing signal
t=0:1:8;
a=2;
y=exp(a*t);
subplot(3,3,2);
stem(t,y);
xlabel('time index');
ylabel('amplitude');
title('exponential growing signal');
%program for exponential decaying signal
t=0:1:8;
a=2;
y=exp(-a*t);
subplot(3,3,3);
stem(t,y);
xlabel('time index');
ylabel('amplitude');
title('exponential decaying signal');
%program for generation of unit impulse
t=-2:1:2;
y=[zeros(1,2),ones(1,1),zeros(1,2)];
subplot(3,3,4);
stem(t,y);
xlabel('time');
ylabel('amplitude');
title('unit impulse signal');
%program for generation of unit step signal
n=input('enter N values');
t=0:1:n-1;
y=ones(1,n);
subplot(3,3,5);
stem(t,y);
xlabel('time');
ylabel('amplitude');
title('unit step signal');
%program for generation of unit ramp signal
t=0:10;
subplot(3,3,6);
stem(t,t);
xlabel('time index');
ylabel('amplitude');
title('unit ramp signal');
OUTPUT:
RESULT:
EXP.NO :3
CONVOLUTION OF TWO SEQUENCES
DATE :
SOFTWARE REQUIRED:
System with MATLAB SOFTWARE
ALGORITHM:
1.Start the MATLAB program.
2.open New M-file .
3.Type the program.
4.Save the program in current directory.
5.Compile and run the program.
6.If any error occur in the program ,correct the error and run the program.
7.For the output see the command window or figure window.
8.Stop the program .
PROGRAM:
x1=[2,1,2,1,2];
x2=[1,-1,1];
y=conv(x1,x2);
subplot(3,1,1);
stem(x1);
xlabel('time index n');
ylabel('amplitude');
title('first sequence x1');
subplot(3,1,2);
stem(x2);
xlabel('time index n');
ylabel('amplitude');
title('second sequence x2');
subplot(3,1,3);
stem(y);
xlabel('time index n');
ylabel('amplitude');
title('convolution of two sequence');
OUTPUT:
THEORETICAL CALCULATION:
RESULT:
EXP.NO : 4
LINEAR CONVOLUTION
DATE :
SOFTWARE REQUIRED:
System with MATLAB
ALGORITHM:
1.Start the MATLAB program.
2.open New M-file .
3.Type the program.
4.Save the program in current directory.
5.Compile and run the program.
6.If any error occur in the program ,correct the error and run the program.
7.For the output see the command window or figure window.
8.Stop the program .
PROGRAM:
x1=[2,1,2,1,2];
x2=[1,-1,1];
y=conv(x1,x2);
subplot(3,1,1);
stem(x1);
xlabel('time index n');
ylabel('amplitude');
title('first sequence x1');
subplot(3,1,2);
stem(x2);
xlabel('time index n');
ylabel('amplitude');
title('second sequence x2');
subplot(3,1,3);
stem(y);
xlabel('time index n');
ylabel('amplitude');
title('convolution of two sequence');
OUTPUT:
THEORETICAL CALCULATION:
RESULT:
EXP.NO : 5
CROSS CORRELATION
DATE :
AIM:
To perform cross-correlation of two discrete time sequences
SOFTWARE REQUIRED:
System with MATLAB SOFTWARE
ALGORITHM:
1.Start the MATLAB program.
2.open New M-file .
3.Type the program.
4.Save the program in current directory.
5.Compile and run the program.
6.If any error occur in the program ,correct the error and run the program.
x1=[4,3,4,2];
x2=[1,3,4,1];
y=xcorr(x1,x2);
subplot(3,1,1);
stem(x1);
xlabel('time index n');
ylabel('amplitude');
title('first sequence x1');
subplot(3,1,2);
stem(x2);
xlabel('time index n');
ylabel('amplitude');
title('sequence x2');
subplot(3,1,3);
stem(y);
xlabel('time index n');
ylabel('amplitude');
title('croos correlation of two sequences');
OUTPUT:
THEORETICAL CALCULATION:
RESULT:
EXP.NO : 6
AUTO CORRELATION
DATE :
AIM:
To perform auto-correlation of two discrete time sequences
SOFTWARE REQUIRED:
System with MATLAB SOFTWARE
ALGORITHM:
1.Start the MATLAB program.
2.open New M-file .
3.Type the program.
4.Save the program in current directory.
5.Compile and run the program.
6.If any error occur in the program , correct the error and run the program.
7.For the output see the command window or figure window.
8.Stop the program .
PROGRAM:
x=[4,3,4,2];
y=xcorr(x);
subplot(2,1,1);
stem(x);
xlabel('time index n');
ylabel('amplitude');
title('sequence x');
subplot(2,1,2);
stem(y);
xlabel('time index n');
ylabel('amplitude');
title('auto correlation of two sequences');
OUTPUT:
THEORETICAL CALCULATION:
RESULT:
EXP.NO : 7
CIRCULAR CONVOLUTION
DATE :
AIM:
To perform circular convolution of two discrete time sequences
SOFTWARE REQUIRED:
System with MATLAB SOFTWARE
ALGORITHM:
1.Start the MATLAB program.
2.open New M-file .
3.Type the program.
4.Save the program in current directory.
5.Compile and run the program.
6.If any error occur in the program ,correct the error and run the program.
7.For the output see the command window or figure window.
8.Stop the program .
PROGRAM:
clc;
clear all;
x=input('enter the first sequence');
h=input('enter the second sequence');
L=length(x);
M=length(h);
N=max(L,M);
x1=[x,zeros(1,N-L)];
h1=[h,zeros(1,N-M)];
y=cconv(x1,h1,N);
disp(y);
l=0:1:L-1;
m=0:1:M-1;
k=0:1:N-1;
subplot(3,1,1);
stem(l,x);
xlabel('time index');
ylabel('amplitude');
title('first sequence x(n)');
subplot(3,1,2);
stem(m,h);
xlabel('time index');
ylabel('amplitude');
title('second sequence h(n)');
subplot(3,1,3);
stem(k,y);
xlabel('time index');
ylabel('amplitude');
title('circular convolution');
OUTPUT:
THEORETICAL CALCULATION:
RESULT:
EXP.NO : 8
SPECTRAL ANALYSIS USING DFT
DATE :
AIM:
To perform frequency spectrum analysis of a signal using MATLAB.
SOFTWARE REQUIRED:
System with MATLAB SOFTWARE
ALGORITHM:
1.Start the MATLAB program.
2.open New M-file .
3.Type the program.
4.Save the program in current directory.
5.Compile and run the program.
6.If any error occur in the program ,correct the error and run the program.
7.For the output see the command window or figure window.
8.Stop the program .
PROGRAM:
clc;
clear all;
close all;
N=256;%total number of samples
fs=8000;%sampling frequency set at 1000hz
f=1000;
n=0:N-1;
%now generate the sinusoidal signal
x=sin(2*(f/fs)*pi*n);
%estimate its spectrum using fft command
X=fft(x);
magX=abs(X);
%Build up an approprite frequency axis
fx=0:(N/2)-1;%first make a vector for f=0,1,2,...(N/2)-1
fx=(fx*fs)/N;%now scale it so that it represents frequencies in Hz
figure(1);
subplot(1,1,1);
plot(fx,20*log10(magX(1:N/2)));
grid;
title('spectrum of a sinusodial signalwith f=1KHz');
xlabel('frequency(Hz)');
ylabel('Magnitude(dB)');
OUTPUT:
RESULT:
EXP.NO : 9
DESIGN OF CHEBYSHEV LOW PASS FILTER
DATE :
AIM:
To design a Chebyshev Low pass filter for the given specifications
SOFTWARE REQUIRED:
System with MATLAB SOFTWARE
ALGORITHM:
1. Get the pass band and stopband wripples
2. Get the passband and stopband edge frequencies.
3. Get the sampling frequency
4. Calculate the order of the filter.
5. Calculate the transfer function of the filter using the window coefficients.
6. Draw the magnitude and phase responses
7. For the output see the command window or figure window.
8. Stop the program .
PROGRAM:
clc;
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
wp=input('enter the pass band frequency in radians');
ws=input('enter the stop band frequency in radians');
T=input('enter the sampling period');
fs=1/T;
rpdb=20*log10(rp);
rsdb=-20*log10(rs);
[n,w]=cheb1ord(wp,ws,rpdb,rsdb,'s');
[b,a]=cheby1(n,rp,w,'s');
[num,den]=bilinear(b,a,1);
%[num,den]=impinvar(b,a,fs);
figure;
freqz(num,den);
title('chebysher low pass filter using bilinear transformation');
figure(2)
[z p k]=tf2zpk(num,den);
zplane(z,p);
OUTPUT:
RESULT:
EXP.NO:10
DESIGN OF CHEBYSHEV BAND PASS DIGITAL FILTER
DATE :
AIM:
To design a Chebyshev band pass filter for the given specifications
SOFTWARE REQUIRED:
System with MATLAB SOFTWARE
ALGORITHM:
1. Get the pass band and stopband wripples
2. Get the passband and stopband edge frequencies.
3. Get the sampling frequency
4. Calculate the order of the filter.
5. Calculate the transfer function of the filter using the window coefficients.
6. Draw the magnitude and phase responses
7. For the output see the command window or figure window.
8. Stop the program.
PROGRAM:
clc;
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
wp1=input('enter the pass band frequency1 in radians');
ws1=input('enter the stop band frequency1 in radians');
T=input('enter the sampling period');
fs=1/T;
rpdb=20*log10(rp);
rsdb=-20*log10(rs);
wp2=input('enter the pass band frequency2 in radians');
ws2=input('enter the stop band frequency2 in radians');
[n,w]=cheb1ord([wp1 wp2],[ws1 ws2],rpdb,rsdb,'s');
[b,a]=cheby1(n,rp,w,'s');
[num,den]=bilinear(b,a,fs);
%[num,den]=impinvar(b,a,fs);
figure;
freqz(num,den);
title('chebysher band pass filter using bilinear transformation');
figure(2)
[z p k]=tf2zpk(num,den);
zplane(z,p);
OUTPUT:
RESULT:
EXP.NO: 11
DESIGN OF BUTTERWORTH LOW PASS FILTER
DATE:
AIM:
To design a Butterworth Low pass filter for the given specifications
SOFTWARE REQUIRED:
System with MATLAB SOFTWARE
ALGORITHM:
1. Get the pass band and stopband wripples
2. Get the passband and stopband edge frequencies.
3. Get the sampling frequency
4. Calculate the order of the filter.
5. Calculate the transfer function of the filter using the window coefficients.
6. Draw the magnitude and phase responses
7. For the output see the command window or figure window.
8. Stop the program.
PROGRAM:
clc;
close all;
clear all;
rp=input('enter the pass band ripple:(default:0.15)');
rs=input('enter the stop band ripple:(default:60)');
wp1=input('enter the pass band frequency1 in radians:(default:1500)');
ws1=input('enter the stop band frequency1 in radians:(default:3000)');
fs=input('enter the sampling frequency :(default:7000)');
w1=2*wp1/fs;
w2=2*ws1/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
[z,p,k]=butter(n,wn);
[b,a]=butter(n,wn,'s');
w=0:0.01:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(om/pi,m);
ylabel('gain in db...');
xlabel('(a)normalised freq');
title('butterworth low pass filter');
subplot(2,1,2);
plot(om/pi,an);
ylabel('phase in db...');
xlabel('(b)normalised freq');
OUTPUT:
RESULT:
EXP.NO :12
DESIGN OF BTTTERWORTH HIGH PASS FILTER
DAT E :
AIM:
To design a Butterworth high pass filter for the given specifications
SOFTWARE REQUIRED:
System with MATLAB SOFTWARE
ALGORITHM:
1. Get the pass band and stopband wripples
2. Get the passband and stopband edge frequencies.
3. Get the sampling frequency
4. Calculate the order of the filter.
5. Calculate the transfer function of the filter using the window coefficients.
6. Draw the magnitude and phase responses
7. For the output see the command window or figure window.
8. Stop the program.
PROGRAM:
OUTPUT:
RESULT:
EXP.NO : 13
DESIGN OF BUTTERWORTH BAND PASS FILTER
DATE :
AIM:
To design a Butterworth Band pass filter for the given specifications
SOFTWARE REQUIRED:
System with MATLAB SOFTWARE
ALGORITHM:
1. Get the pass band and stopband wripples
2. Get the passband and stopband edge frequencies.
3. Get the sampling frequency
4. Calculate the order of the filter.
5. Calculate the transfer function of the filter using the window coefficients.
6. Draw the magnitude and phase responses
7. For the output see the command window or figure window.
8. Stop the program.
PROGRAM:
clc;
clear all;
close all;
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
wp1=input('enter the pass band frequency1 in radians');
ws1=input('enter the stop band frequency1 in radians');
T=input('enter the sampling period');
fs=1/T;
rpdb=20*log10(rp);
rsdb=20*log10(rs);
wp2=input('enter the pass band frequency2 in radians');
ws2=input('enter the stop band frequency2 in radians');
[n,wn]=buttord([wp1 wp2],[ws1 ws2],rpdb,rsdb,'s')
[b,a]=butter(n,wn,'s');
[num,den]=bilinear(b,a,fs);
%[num,den]=impinvar(b,a,fs);
figure;
freqz(num,den);
title('butterworth band pass filter using bilinear trasformation');
figure(2)
[z p k]=tf2zpk(num,den);
zplane(z,p);
OUTPUT:
RESULT:
EXP.NO: 14
DESIGN OF FIR LOW PASS FILTER USING FOURIER SERIES METHOD
DATE :
AIM:
To design a low pass FIR filter using Fourier series method with given cutoff frequencies and
length of Sequnce
SOFTWARE REQURIED:
ALGORITHM:
1. Get the order of the filter
2. Get the cutoff frequency of the filter
3. Find the Filter coefficients.
4. Draw the magnitude and phase response.
PROGRAM:
clc;
clear all;
close all;
N=15;
alpha=(N-1)/2;
wc=0.5*pi;
for n=0:1:(N-1);
if(n~=alpha)
h1=sin(wc*(n-alpha))/(pi*(n-alpha));
else
h1=(wc/pi);
end
hd(n+1)=h1;
end
disp('output');hd
freqz(hd,1);
title('LOW PASS FIR FILTER USING FOURIER SERIES');
OUTPUT:
RESULT:
EXP.NO: 15
DESIGN OF HIGH PASS FIR FILTER USING FOURIER SERIES METHOD
DATE :
AIM:
To design a High pass FIR filter using Fourier series method with given cutoff
frequencies and length of Sequence
SOFTWARE REQURIED:
OUTPUT:
RESULT:
EXP.NO: 16
DESIGN OF BAND PASS FIR FILTER USING FOURIER SERIES
METHOD
DATE :
AIM:
To design a Band Pass FIR filter using Fourier series method with given cutoff
frequencies and length of Sequnce
SOFTWARE REQURIED:
OUTPUT:
RESULT:
EXP.NO: 17
DESIGN OF BAND STOP FIR FILTER USING FOURIER SERIES
METHOD
DATE :
AIM:
To design a Band Stop FIR filter using Fourier series method with given cutoff
frequencies and length of Sequnce
SOFTWARE REQURIED:
OUTPUT:
RESULT:
EXP.NO: 18
DESIGN OF LOW PASS FIR FILTER USING HANNING WINDOW METHOD
DATE :
AIM:
To design a Low Pass FIR filter using Hanning Window method with given cutoff
frequencies and length of Sequnce
SOFTWARE REQURIED:
OUTPUT:
RESULT:
EXP.NO: 19
DESIGN OF HIGH PASS FIR FILTER USING HANNING WINDOW METHOD
DATE :
AIM:
To design a High Pass FIR filter using Hanning Window method with given cutoff
frequencies and length of Sequnce
SOFTWARE REQURIED:
clc;
clear all;
close all;
N=15;
alpha=(N-1)/2;
wc=0.5*pi;
for n=0:1:(N-1);
if(n~=alpha)
h1=-sin(wc*(n-alpha))/(pi*(n-alpha));
else
h1=1-(wc/pi);
end
hd(n+1)=h1;
end
wn=hanning(N);
hn=hd.*wn';
disp('output');hn
freqz(hn,1);
title('HIGH PASS FIR FILTER USING HANNING WINDOW');
figure(2);
z=roots(hn)
zplane(z);
title('zero locations');
OUTPUT:
RESULT:
EXP.NO: 20
DESIGN OF BAND PASS FIR FILTER USING HANNING WINDOW METHOD
DATE :
AIM:
To design a Band Pass FIR filter using Hanning Window method with given cutoff
frequencies and length of Sequnce
SOFTWARE REQURIED:
OUTPUT:
RESULT:
EXP.NO: 21
DESIGN OF BAND STOP FIR FILTER USING HANNING WINDOW METHOD
DATE :
AIM:
To design a Band Stop FIR filter using Hanning Window method with given cut-off
frequencies and length of Seqeunce
SOFTWARE REQURIED:
OUTPUT:
RESULT:
EXP.NO: 22
MULTIRATE FILTERING
DATE :
AIM:
To perform Multirate filtering operation of signals using MATLAB
SOFTWARE REQURIED:
ALGORITHM:
1.Start the MATLAB program.
2.open New M-file .
3.Type the program.
4.Save the program in current directory.
5.Compile and run the program.
6.If any error occur in the program ,correct the error and run the program.
7.For the output see the command window or figure window.
8.Stop the program .
PROGRAM:
Upsampling or interpolation:
clc;
clear all;
close all;
close all;
x=[1 2 3 4 5 6 7 8];
N=length(x);
n=0:1:N-1;
L1=2;
y1=upsample(x,L1);
L2=3;
y2=upsample(x,L2);
m1=1:1:(N*L1);
subplot(3,1,1);
stem(n,x);
subplot(3,1,2);
stem(m1-1,y1);
m2=1:1:(N*L2);
subplot(3,1,3);
stem(m2-1,y2);
title('Upsampled sequence');
Downsampling or decimation:
clc;
clear all;
close all;
close all;
x=[1 2 3 4 5 6 7 8 9];
N=length(x);
D1=2;
y1=upsample(x,D1);
D2=3;
y2=upsample(x,D2);
subplot(3,1,1);
stem(x);
xlabel('n----->');
ylabel('Mag---->');
subplot(3,1,2);
stem(y1);
xlabel('m----->');
ylabel('Mag---->');
subplot(3,1,3);
stem(y2);
xlabel('m----->');
ylabel('Mag---->');
title('downsampled sequence')
OUTPUT:
RESULT: