Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

Lab-7(a): To find and plot the frequency response of continuous time causal LTI system

described by constant coefficient differential equation (1st order system).


%write mag. in original form for CTFT
%2cndy/dt+8y(t)=(cn/2)x(t)

MATLAB CODE:-
t=0:.05:10;
cn=32;
b=[cn 8];
a=[cn/2];
w=0:.05:4*pi;
%1st mag. of num, then mag of denum
y=freqs(a,b,w);
subplot(3,1,1)
plot(abs(y))
gridon
xlabel('w------->>')
title('CT freq. response of 1st Order Diff. Eqn')
ylabel('|H(jw)|------>>')

h=.5*exp(-1*t/4);
subplot(3,1,2)
plot(h)
ylim([-.1 1])
xlim([0 200])
gridon
xlabel('t------>>')
ylabel('h(t)------>>')

u=heaviside(t);
s=conv(h,u);
subplot(3,1,3)
plot(s)
ylim([-1 40])
xlim([0 400])
gridon
xlabel('t------>>')
ylabel('s(t)----->>')
CT freq. response of 1st Order Diff. Eqn
2
|H(jw)|------>>
1.5

0.5

0
0 50 100 150 200 250 300
w------->>

1
h(t)------>>

0.5

0
0 20 40 60 80 100 120 140 160 180 200
t------>>

40

30
s(t)----->>

20

10

0
0 50 100 150 200 250 300 350 400
t------>>
Lab-7(b): To find and plot the frequency response of continuous time causal LTI system
described by constant coefficient differential system(2nd order system).

MATLAB CODE:-
%write mag. in original form for CTFT
%2cndy^2/dt^2-(cn+3)dy/dt+yt=cn/2dx/dt

t=0:.05:10;
cn=70;
b=[2*cn -(cn+3) 1];
a=[cn/2 0];
w=0:.05:4*pi;
%1st mag. of num, then mag of denum
y=freqs(a,b,w);
subplot(3,1,1)
plot(abs(y))
gridon
xlabel('w------->>')
title('CT freq. response of 2nd Order Diff. Eqn')
ylabel('|H(jw)|------>>')

h=exp(-4*t/3);
subplot(3,1,2)
plot(h)
ylim([-.1 1])
xlim([0 200])
gridon
xlabel('t------>>')
ylabel('h(t)------>>')

u=heaviside(t);
s=conv(h,u);
subplot(3,1,3)
plot(s)
ylim([-1 17])
xlim([0 400])
gridon
xlabel('t------>>')
ylabel('s(t)----->>')
Graph of 2ndOrder Diffeential Equation:

CT freq. response of 1st Order Diff. Eqn


0.8
|H(jw)|------>>

0.6

0.4

0.2

0
0 50 100 150 200 250 300
w------->>

1
h(t)------>>

0.5

0
0 20 40 60 80 100 120 140 160 180 200
t------>>

15
s(t)----->>

10

0
0 50 100 150 200 250 300 350 400
t------>>
Lab-8(a): To find and plot the Fourier transform of discrete time periodic signals.
MATLAB CODE:-
% DTFT of Periodic Function
symsn
x=cos(2*n*pi/5);
fourier(x)
w=2*pi/5
X=pi*(dirac(w - (2*pi)/5) + dirac((2*pi)/5 + w))

stem(X)

Graph of DTFT of Periodic Ftn:


X[n]=cos(2pi/5);
|X(e^jw)|=pi*(dirac(w - (2*pi)/5) + dirac((2*pi)/5 + w))

0.8
|X(ejw)|--------->>

0.6

0.4

0.2

0
-4 -3 -2 -1 0 1 2 3 4
n---->>
Lab-8(b): To find and plot the Fourier transform of discrete time Aperiodic signals.
MATLAB CODE:.
n=0:1:50;
a=1/4;
w=-3*pi:.085:3*pi;
%x[n]=a^n*u[n] // u[n]:heaviside
u=heaviside(n);
xlim([-10 100]);
ylim([-2 4])
x=a.^n.*u
y=fft(x)
subplot(2,1,1)
plot(abs(y))
title('fourier transform ');
xlabel('w...>');
ylabel('amplitude');
gridon
fourier transform
X=1./sqrt(1+a*a-2*a*cos(w))
1
subplot(2,1,2)
plot(w,X)
0.8
title('fourier transform');
amplitude

xlabel('w...>');
0.6
ylabel('amplitude');
gridon
0.4

Graph of DTFT of APeriodicFtn:


0.2
0 10 20 30 40 50 60
w...>
fourier transform
1.6

1.4
amplitude

1.2

0.8
-10 -8 -6 -4 -2 0 2 4 6 8 10
w...>
Lab-9(a):To find and plot the frequency response of discrete time causal LTI system
represented by constant coefficient difference equation (1st order system).

MATLAB CODE:-
%Difference equation
% 2y[n]-3y [n-1] =3x[n]

a= [-3 2];
b= [3];
w=0:.05:4*pi;
y=freqz(b,a);
plot(abs(y),'linewidth',2)
xlim([0 500])
ylim([0 3.2])
xlabel('w----->>')
ylabel('|H(e^jw)|---->>')
title('Freq. Response of 1st Order Difference Eqn.')
gridon

Graph:

Freq. Response of 1st Order Difference Eqn.

2.5

2
|H(ejw)|---->>

1.5

0.5

0
0 50 100 150 200 250 300 350 400 450 500
w----->>
Lab-9(b): To find and plot the frequency response of discrete time causal LTI system
represented by constant coefficient difference equation(2nd order system).
MATLAB CODE:-
%write mag. in reverse for DTFT
% 2nd Order Difference equation
% 3y[n]-4y[n-1]+2y[n-1]=x[n]-3x[n-1]

b=[2 -4 3];
a=[-3 1];
%w=0:.05:4*pi;
%1st mag. of num, then mag of denum
y=freqz(a,b);
plot(abs(y),'linewidth',2)
xlim([0 500])
ylim([0 4])
xlabel('w----->>')
ylabel('|H(e^jw)|---->>')
title('Freq. Response of 2nd Order Difference Eqn.')
gridon

Graph:

Freq. Response of 2nd Order Difference Eqn.


4

3.5

2.5
|H(ejw)|---->>

1.5

0.5

0
0 50 100 150 200 250 300 350 400 450 500
w----->>
Lab-10(a): To study the time and frequency characteristics of LTI system represented by
constant coefficient differential equation i-e frequency ,impulse and step response.
MATLAB CODE:-
%1st Order Butterworth Filter

t=0:.1:15;
wc=1/4;
a=[wc];
b=[1 wc];
H=freqs(a,b)
subplot(3,3,1)
plot(abs(H))
gridon
title('First Order Butterworth Filter a=1/4')
xlabel('freq---->>')
ylabel('Magnitude---->>')
xlim([0 200])
ylim([0 1.2])

h=wc*exp(-wc*t)
subplot(3,3,2)
plot(h)
ylim([0 .8])
title('Impulse Response ')
xlabel('time---->>')
ylabel('Magnitude---->>')
gridon
xlim([0 150])

s=1-exp(-wc*t)
subplot(3,3,3)
plot(s)
title('Step Response ')
xlabel('time---->>')
ylabel('Magnitude---->>')
gridon
ylim([0 1.2])
xlim([0 150])

wc=2/4;
a=[wc];
b=[1 wc];
H=freqs(a,b)
subplot(3,3,4)
plot(abs(H))
title('First Order Butterworth Filter a=2/4')
xlabel('time---->>')
ylabel('Magnitude---->>')
gridon
xlim([0 200])
ylim([0 1.2])

h=wc*exp(-wc*t)
subplot(3,3,5)
plot(h)
title('Impulse Response ')
xlabel('time---->>')
ylabel('Magnitude---->>')
ylim([0 .8])
gridon
xlim([0 200])

s=1-exp(-wc*t)
subplot(3,3,6)
plot(s)
title('Step Response ')
xlabel('time---->>')
ylabel('Magnitude---->>')
gridon
ylim([0 1.2])
xlim([0 150])

wc=3/4;
a=[wc];
b=[1 wc];
H=freqs(a,b)
subplot(3,3,7)
plot(abs(H))
title('First Order Butterworth Filter a=3/4')
xlabel('freq---->>')
ylabel('Magnitude---->>')
gridon
xlim([0 200])
ylim([0 1.2])

h=wc*exp(-wc*t)
subplot(3,3,8)
plot(h)
title('Impulse Response ')
xlabel('time---->>')
ylabel('Magnitude---->>')
ylim([0 .8])
gridon

s=1-exp(-wc*t)
subplot(3,3,9)
plot(s)
ylim([0 1.2])
title('Step Response ')
xlabel('time---->>')
ylabel('Magnitude---->>')
gridon
xlim([0 150])
First Order Butterworth Filter a=1/4 Impulse Response Step Response
0.8
1 1
Magnitude---->>

Magnitude---->>

Magnitude---->>

0.6
0.4
0.5 0.5
0.2
0 0 0
0 50 100 150 200 0 50 100 150 0 50 100 150
freq---->> time---->> time---->>
First Order Butterworth Filter a=2/4 Impulse Response Step Response
0.8
1 1
Magnitude---->>

Magnitude---->>

Magnitude---->>
0.6
0.4
0.5 0.5
0.2
0 0 0
0 50 100 150 200 0 50 100 150 200 0 50 100 150
time---->> time---->> time---->>
First Order Butterworth Filter a=3/4 Impulse Response Step Response
0.8
1 1
Magnitude---->>

Magnitude---->>

Magnitude---->>
0.6
0.4
0.5 0.5
0.2
0 0 0
0 50 100 150 200 0 50 100 150 200 0 50 100 150
freq---->> time---->> time---->>
Graph:
Lab#10(b): To study the time and frequency characteristics of LTI system represented by
constant coefficient differential equation i-e frequency, impulse and step response(2nd
order system)
MATLAB CODE:-
%2nd Order Butterworth Filter

t=0:.1:15;
wc=1/4;
a=[wc*wc];
b=[1 wc*sqrt(2) wc*wc];
H=freqs(a,b)
subplot(3,3,1)
plot(abs(H))
gridon
title('Second Order Butterworth Filter a=1/4')
xlabel('freq---->>')
ylabel('Magnitude---->>')
xlim([0 200])
ylim([0 1.2])

h=-2*i*wc*exp(-wc*t/2).*sin(wc*t/2);
subplot(3,3,2)
plot(abs(h))
ylim([0 .5])
title('Impulse Response ')
xlabel('time---->>')
ylabel('Magnitude---->>')
gridon
xlim([0 150])

s=1-exp(-wc*t)
subplot(3,3,3)
plot(s)
title('Step Response ')
xlabel('time---->>')
ylabel('Magnitude---->>')
gridon
ylim([0 1.2])
xlim([0 150])

wc=2/4;
a=[wc];
b=[1 wc];
H=freqs(a,b)
subplot(3,3,4)
plot(abs(H))
title('Second Order Butterworth Filter a=2/4')
xlabel('time---->>')
ylabel('Magnitude---->>')
gridon
xlim([0 200])
ylim([0 1.2])

h=-2*i*wc*exp(-wc*t/2).*sin(wc*t/2);
subplot(3,3,5)
plot(abs(h))
title('Impulse Response ')
xlabel('time---->>')
ylabel('Magnitude---->>')
ylim([0 .5])
gridon
xlim([0 150])

s=1-exp(-wc*t)
subplot(3,3,6)
plot(s)
title('Step Response ')
xlabel('time---->>')
ylabel('Magnitude---->>')
gridon
ylim([0 1.2])
xlim([0 150])

wc=3/4;
a=[wc];
b=[1 wc];
H=freqs(a,b)
subplot(3,3,7)
plot(abs(H))
title('Second Order Butterworth Filter a=3/4')
xlabel('freq---->>')
ylabel('Magnitude---->>')
gridon
xlim([0 200])
ylim([0 1.2])

h=-2*i*wc*exp(-wc*t/2).*sin(wc*t/2);
subplot(3,3,8)
plot(abs(h))
title('Impulse Response ')
xlabel('time---->>')
ylabel('Magnitude---->>')
gridon
xlim([0 150])
ylim([0 .5])

s=1-exp(-wc*t)
subplot(3,3,9)
plot(s)
ylim([0 1.2])
title('Step Response ')
xlabel('time---->>')
ylabel('Magnitude---->>')
gridon
xlim([0 150])
Second Order Butterworth Filter a=1/4 Impulse Response Step Response
1 0.4 1
Magnitude---->>

Magnitude---->>

Magnitude---->>

0.3
0.5 0.2 0.5
0.1
0 0 0
0 50 100 150 200 0 50 100 150 0 50 100 150
freq---->> time---->> time---->>
Second Order Butterworth Filter a=2/4 Impulse Response Step Response
1 0.4 1
Magnitude---->>

Magnitude---->>

Magnitude---->>
0.3
0.5 0.2 0.5
0.1
0 0 0
0 50 100 150 200 0 50 100 150 0 50 100 150
time---->> time---->> time---->>
Second Order Butterworth Filter a=3/4 Impulse Response Step Response
1 1
Magnitude---->>

Magnitude---->>

Magnitude---->>
0.4
0.3
0.5 0.2 0.5
0.1
0 0 0
Graph: 0 50 100 150 200 0 50 100 150 0 50 100 150
freq---->> time---->> time---->>

You might also like