You are on page 1of 16

Exp No: Page No:

Date :

LINEAR CONVOLUTION

AIM:

To verify Linear Convolution.

EQUIPMENT:

1. Operating System : Windows XP


2. Constructor : Simulator
3. Software : Matlab Software

PROGRAM:

x=input('Enter the first sequence: ');


h=input('Enter the second sequence: ');
y=conv(x,h);
subplot (3,1,1);
stem(x);
xlabel('a(n)');
ylabel('Amplitude');
subplot (3,1,2);
stem (h);
xlabel('b(n)');
ylabel('Amplitude');
subplot (3,1,3);
stem (y);
xlabel('c(n)');
ylabel('Amplitude');
disp('The resultant signal is : ');y

Sri Chundi Ranganayakulu Engineering College


Exp No: Page No:
Date :

RESULT:

Sri Chundi Ranganayakulu Engineering College


Exp No: Page No:
Date :

CIRCULAR CONVOLUTION

AIM:

To verify Circular Convolution.

EQUIPMENT:

1. Operating System : Windows XP


2. Constructor : Simulator
3. Software : Matlab Software

PROGRAM:

x=[1 1 1 1 2];
h=[1 2 1 1];
nx=length(x);
nh=length(h);
N=max(nx,nh);
y=cconv(x,h,N);
n=0:1:nx-1;
subplot(2,2,1);
stem(n,x);
xlabel('-->n');
ylabel('-->x(n)');
title('input sequence');
n=0:1:nh-1;
subplot(2,2,2);
stem(n,h);
xlabel('-->n');
ylabel('-->x(n)');
title('imulse sequence');
n=0:1:N-1;

Sri Chundi Ranganayakulu Engineering College


Exp No: Page No:
Date :

subplot(2,2,3);
stem(n,y);
xlabel('-->n');
ylabel('-->x(n)');
title('resultant sequence');y

RESULT:

Sri Chundi Ranganayakulu Engineering College


Exp No: Page No:
Date :

RECTANGULAR WINDOW
AIM:
To design FIR filter using rectangular window technique.
EQUIPMENT:
1. Operating System : Windows XP
2. Constructor : Simulator
3. Software : Matlab Software
PROGRAM:
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter the passband freq');
fs=input('enter the stopband freq');
f=input('enter the sampling freq');
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; end;
y=boxcar(n1);
b=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('(a) normalized freq');
b=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('(b) normalized freq');

Sri Chundi Ranganayakulu Engineering College


Exp No: Page No:
Date :

wn=[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('(c) normalized freq');
b=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('(c) normalized freq');
RESULT:

Sri Chundi Ranganayakulu Engineering College


Exp No: Page No:
Date :

TRIANGULAR WINDOW
AIM:
To design FIR filter using triangular window technique.
EQUIPMENT:
1. Operating System : Windows XP
2. Constructor : Simulator
3. Software : Matlab Software
PROGRAM:
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter the passband freq');
fs=input('enter the stopband freq');
f=input('enter the sampling freq');
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; end;
y=bartlett(n1);
b=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('(a) normalized freq');
b=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('(b) normalized freq');

Sri Chundi Ranganayakulu Engineering College


Exp No: Page No:
Date :

wn=[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('(c) normalized freq');
b=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('(c) normalized freq');
RESULT:

Sri Chundi Ranganayakulu Engineering College


Exp No: Page No:
Date :

KAISER WINDOW
AIM:
To design FIR filter using kaiser window technique.
EQUIPMENT:
1. Operating System : Windows XP
2. Constructor : Simulator
3. Software : Matlab Software
PROGRAM:
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter the passband freq');
fs=input('enter the stopband freq');
f=input('enter the sampling freq');
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; end;
y=kaiser(n1,beta);
b=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('(a) normalized freq');
b=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');

Sri Chundi Ranganayakulu Engineering College


Exp No: Page No:
Date :

xlabel('(b) normalized freq');


wn=[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('(c) normalized freq');
b=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('(c) normalized freq');
RESULT:

Sri Chundi Ranganayakulu Engineering College


Exp No: Page No:
Date :

GENERATION OF SUM OF SINUSOIDAL SIGNALS


AIM:
To write a Matlab program to generate sum of sinusoidal
signals.
EQUIPMENT:
1. Operating System : Windows XP
2. Constructor : Simulator
3. Software : Matlab Software
PROGRAM:
clc;
clear all;
close all;
tic;
t=0:0.01:pi;
y1=sin(t);
y2=sin(3*t)/3;
y3=sin(5*t)/5;
y4=sin(7*t)/7;
y5=sin(9*t)/9;
y6=sin(11*t)/11;
y=y1+y2+y3+y4+y5+y6;
plot(t,y,t,y1,t,y2,t,y3,t,y4,t,y5,t,y6);
legend('y','y1','y2','y3','y4','y5','y6');
title('Generation of sum of sine waves');
grid;
xlabel('---->t');
ylabel('--->amplitude');
toc;

Sri Chundi Ranganayakulu Engineering College


Exp No: Page No:
Date :

RESULT:

Sri Chundi Ranganayakulu Engineering College


Exp No: Page No:
Date :

ANALOG LOWPASS FILTER


AIM:
To write a Matlab program to find frequency response of
Analog Lowpass Filter.

EQUIPMENT:
1. Operating System : Windows XP
2. Constructor : Simulator
3. Software : Matlab Software
PROGRAM:
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband freq');
ws=input('enter the stopband freq');
fs=input('enter the sampling freq');
w1=2*wp/fs;
w2=2*ws/fs;
w=0:0.01:pi;
[n,wn]=buttord(w1,w2,rp,rs,'s');
[b,a]=butter(n,wn,'s');
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
subplot(2,1,1);
plot(om/pi,m);
xlabel('normalised freq');
ylabel('gain in db');
title('design of butterworth filter');
an=angle(h);
subplot(2,1,2);
plot(om/pi,an);
xlabel('normalised freq');
ylabel('phase in radians');

Sri Chundi Ranganayakulu Engineering College


Exp No: Page No:
Date :

RESULT:

Sri Chundi Ranganayakulu Engineering College


Exp No: Page No:
Date :

ANALOG HIGHPASS FILTER


AIM:
To write a Matlab program to find frequency response of
Analog Highpass Filter.

EQUIPMENT:
1. Operating System : Windows XP
2. Constructor : Simulator
3. Software : Matlab Software

PROGRAM:
rp=input('enter the pass band ripple');
rs=input('enter the stop band filter');
ws=input('enter the pass band freq');
wp=input('enter the stop band freq');
fs=input('enter the sampling freq');
w1=2*wp/fs;
w2=2*ws/fs;
w=0:0.01:pi;
[n,wn]=buttord(w1,w2,rp,rs,'s');
[b,a]=butter(n,wn,'high','s');
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
subplot(2,1,1);
plot(om/pi,m);
xlabel('normalized freq');
ylabel('gain in db');
title('design of butter worth high pass filter');
an=angle(h);
subplot(2,1,2);
plot(om/pi,an);
xlabel('normalized freq');
ylabel('phase in radians');

Sri Chundi Ranganayakulu Engineering College


Exp No: Page No:
Date :

RESULT:

Sri Chundi Ranganayakulu Engineering College

You might also like