DLS - Lab Manual PDF
DLS - Lab Manual PDF
Practical: 1
Aim: Generate an impulse, step, and square waveforms in continuous and discrete domain.
t = (-1:0.05:1);
impulse = t==0;
plot(t,[impulse]);
xlabel('Time')
ylabel ('Magnitude')
title ('Unit Impulse')
t = (-1:0.05:1);
unitstep = t>=0;
plot(t,[unitstep]);
xlabel('Time')
ylabel ('Magnitude')
title ('Unit Step')
2
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
t = (-1:0.05:1);
unitstep = t>=0;
ramp = t.*unitstep;
plot(t,[ramp]);
xlabel('Time')
ylabel ('Magnitude')
title ('ramp')
t = (-1:0.05:1);
unitstep = t>=0;
parabolic = t.^2.*unitstep;
plot(t,[parabolic]);
xlabel('Time')
ylabel ('Magnitude')
title ('parabolic')
t = (-1:0.05:1)';
impulse = t==0;
stem ([impulse]);
xlabel('Time')
ylabel ('Magnitude')
title ('Unit Impulse')
3
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
t = (-1:0.05:1)';
unitstep = t>=0;
stem ([unitstep]);
xlabel('Time')
ylabel ('Magnitude')
title ('Unit Step')
4
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
Assignment:
(1) List and explain in Brief the Commands of MATLAB used to generate different Signals in this
practical.
(2) List out Properties of Continuous and Discrete Time Signals Properties.
(3) Generate Signals with different magnitude and frequencies using MATLAB, Attach their Code
and Plot Figure with this Assignment.
5
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
Practical: 2
Aim: Generate sinusoidal waveforms of different frequencies in continuous and discrete domain.
Understand the difference between CT and DT waveforms.
Sine Wave:
• Frequency: 60 Hz.
• One Cycle: 1/60 =0.0166 seconds
• Radian Frequency: 2*pi*60
t = 0:1/2000:.05; t = 0:1/2000:.05;
x = sin(2*pi*60*t); % approx. to x = sin(2*pi*60*t); % approx. to
continuous-time continuous-time
axis([0 0.05 -1 1]); axis([0 0.05 -1 1]);
plot(t,x) stem(t,x)
xlabel('Time') xlabel('Time')
ylabel ('Magnitude') ylabel ('Magnitude')
title ('Sine Wave') title ('Sine Wave')
Assignment:
(1) Calculate Amplitude and Frequency ( in Hz and Rad/Sec) for the above example.
(2) Generate Sine Wave for
(1) Amplitude: 3.5 Peak, Frequency: 100 Hz
(2) Amplitude: 5 Peak To Peak, Frequency: 250 Rad/Sec
(3) Amplitude: 1000 Peak, Frequency: 2000 Rad/Sec
6
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
Practical: 3
Aim: Generate growing exponential, decaying exponential and exponentially damped sinusoidal signals.
Exponential Signal
𝒙 = 𝑩. 𝒆−𝒂𝒕 𝒙 = 𝑩. 𝒆𝒂𝒕
B=5; B=5;
a=6; a=6;
t=0:.001:1; t=0:.001:1;
x=B*exp(-a*t); x=B*exp(a*t);
plot(t,x) plot(t,x)
xlabel('Time'); xlabel('Time');
ylabel ('Magnitude'); ylabel ('Magnitude');
title ('Decaying Exponential'); title ('Growing Exponential');
𝒙 = 𝑨 𝒔𝒊𝒏(𝝎𝟎 𝒕 + ∅) 𝒆−𝒂𝒕
MATLAB CODE:
A = 60;
w0 = 20*pi;
phi = 0;
a = 6;
t = 0:.001:1;
7
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
Assignment:
(1) Calculate Time Constant of the Exponential from Plot for above example.
(2) Generate Decaying Exponential for RC Circuit using Network Equation.
(3) Generate Growing Damped Sinusoid and show its plot.
8
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
Practical: 4
Aim: Find the discrete/continuous convolution between two sequences/signals. Verify the commutative,
distributive and associative properties of convolution.
Examples:
1. Create vectors u and v containing the coefficients of the polynomials x2+1 and 2x+7.
w = 1×4
2 7 2 7
w contains the polynomial coefficients for 2x3+7x2+2x+7. The same is shown in plot:
Properties of Convolution:
9
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
Commutative: u [1 0 1] ∗ v [2 7] = v [2 7 ] ∗ u [1 0 1]
u = [1 0 1];
v = [2 7];
w = conv (v, u);
subplot(4,1,1);
stem(u,'linewidth', 2);
xlabel('time');
ylabel('u');
subplot(4,1,2);
stem(v,'linewidth', 2);
xlabel('time');
ylabel('v');
subplot(4,1,3);
stem(w,'linewidth', 2);
xlabel('time');
ylabel('w');
Matlab Code:
u = [1 1];
v = [1 2];
w = [1 3];
x = conv (u, v);
y = conv (x, w);
z = conv (v, w);
a = conv (u, z);
subplot(5,1,1);
stem(u, 'linewidth', 2);
xlabel('time');
ylabel('u');
subplot(5,1,2);
stem(v,'linewidth', 2);
xlabel('time');
ylabel('v');
10
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
subplot(5,1,3);
stem(w,'linewidth', 2);
xlabel('time');
ylabel('w');
subplot(5,1,4);
stem(y,'linewidth', 2);
xlabel('time');
ylabel('y');
subplot(5,1,5);
stem(a,'linewidth', 2);
xlabel('time');
ylabel('a');
11
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
Practical: 5
Aim: Perform folding, shifting and scaling on a given signal x (t) to obtain a signal of the form x(at+b).
Folding of Signal:
Matlab Code:
x=input('enter the sequence'); Input
a=length(x); Signal : [1 2 3 4 -1 -2 -3 -4]
n=1:1:a;
subplot(2,1,1); Output
stem(n,x); Folded signal: [-4 -3 -2 -1 4 3 2 1]
xlabel('number of samples');
ylabel('amplitude');
title('input signal');
m=-a:1:-1;
y=x(a-n+1);
subplot(2,1,2);
stem(m,y);
xlabel('number of samples');
ylabel('amplitude');
title('folded signal');
display(x);
display(y);
display(n);
display(m);
Output Plot
12
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
Output Plot:
13
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
t = (-1:0.01:1)';
impulse = t==0;
unitstep = t>=0;
ramp = t.*unitstep;
ramp2 = 2.*t.*unitstep;
plot(t,[ramp ramp2])
t = 0:1/20000:.03;
a = 2;
b = 0.0166;
x = sin(2*pi*60*t); % approx. to
continuous-time
y = sin(2*pi*60*a*t + b);
axis([0 0.06 -1.5 1.5]);
subplot(211);
plot(t,x);
xlabel('Time')
ylabel ('x = sin(2*pi*60*t)')
title ('x(t)')
subplot(212);
plot(t,y);
xlabel('Time')
ylabel ('y = sin(2*pi*60*a*t + b)')
title ('x(at +b)')
14
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
Practical: 6
Aim: Find the output of the system with given input (e.g. x[n]=2 {u[n+2] – u[n-12]}) and given impulse
response ( e.g. h[n]= 0.9n {u[n+2] – u[n-12] }.
t =-5:0.8:20
v = 2.*(heaviside(t+2)-heaviside(t-
12));
h = (0.9).^t.*(heaviside(t+2)-
heaviside(t-12));
subplot(311);
stem(v,'linewidth',1);
xlabel('Time')
ylabel ('v')
title ('signal')
subplot(312);
stem(h,'linewidth',1);
xlabel('Time')
ylabel ('h')
title ('impulse')
y=conv(v,h);
subplot(313);
stem(y,'linewidth',1);
xlabel('Time')
ylabel ('y')
title ('output')
15
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
Practical: 7
Compute and plot the impulse response h[n], 0 ≤ n ≤ 40 using the function h = impz(b, a, N).
Matlab Code:
xn = ones(1,41);
num = [0.18 0.1 0.3 0.1 0.18];
den = [1 -1.15 1.15 -0.7
0.25];
hn = impz(num, den, 41);
stem([0:40], hn);
16
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
Practical: 8
Aim: Compute FT and DTFT of the continuous time signals and discrete time sequences.
Determine the discrete time Fourier transform of x(𝑛) = 0.5𝑛 𝑢(𝑛). Evaluate (𝑒𝑗𝜔) at 501 equispaced points
between [0,π] and plot its magnitude, angle, real, and imaginary parts.
Signal is : x(𝑛) = 0.5𝑛 𝑢(𝑛)
The discrete time fourier transform of signal is:
Matlab Code:
n=[-0.000001:0.1:30];
x=0.5.^n.*(heaviside(n));
plot(n,x);
It is clear from the signal plot, that it is exponentially decaying with rate of 0.5^n.
17
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
w=[0:1:500]*pi/500;
X= exp(j*w) ./ (exp(j*w) -
0.5*ones(1,501));
magX = abs (X);
angX = angle(X);
realX = real(X);
imagX = imag(X);
subplot(2,2,1);
plot(w/pi, magX); grid
xlabel('frequency in pi units');
title('Magnitude Part');
ylabel('Magnitude');
subplot(2,2,3);
plot(w/pi, angX); grid
xlabel('frequency in pi units');
title('Angle Part');
ylabel('Radians');
subplot(2,2,2);
plot(w/pi, realX); grid
xlabel('frequency in pi units');
title('Real Part');
ylabel('Real');
subplot(2,2,4);
plot(w/pi, imagX); grid
xlabel('frequency in pi units');
title('Imaginary Part');
ylabel('Imaginary');
18
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
Practical: 9
Syntax Used:
[ro,po,ko] = residuez(bi,ai)
[bo,ao] = residuez(ri,pi,ki)
[ro,po,ko] = residuez(bi,ai) Finds the residues, poles, and direct terms of a partial fraction
expansion of the ratio of numerator and denominator
polynomials, b and a.
[bo,ao] = residuez(ri,pi,ki) With three input arguments and two output arguments, converts the
partial fraction expansion back to polynomials with coefficients in row
vectors b and a.
Example: Compute the partial-fraction expansion corresponding to the third-order IIR low pass filter
described by the transfer function.
b0 = 0.05634;
b1 = [1 1];
b2 = [1 -1.0166 1];
a1 = [1 -0.683];
a2 = [1 -1.4461 0.7957];
b = b0*conv(b1,b2);
a = conv(a1,a2);
[r,p,k] = residuez(b,a)
zplane(b,a);
hold on
plot(p,'^r')
hold off
[bn,an] = residuez(r,p,k)
19
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
Residuez returns r=roots, p=poles and k=constants representing partial fraction expansion.
r =
-0.1153 - 0.0182i
-0.1153 + 0.0182i
0.3905 + 0.0000i
p =
0.7230 + 0.5224i
0.7230 - 0.5224i
0.6830 + 0.0000i
k =
-0.1037
20
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
Practical: 10
Aim: Given an LTI system with transfer function, plot its (i) pole-zero plot in the z-plane and (ii) frequency
response.
Given that
The poles of the system function are at z = 0.9_ ± π/3. Hence the ROC of this causal system is |z| > 0.9. Therefore
jω
the unit circle is in the ROC, and the discrete-time Fourier transform H(e ) exists.
21
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
w=[0:1:500]*pi/500;
b = [0,1,1];
a = [1,-0.9,0.81];
[R,p,C]= residuez(b,a)
[H,w] = freqz(b,a,100);
subplot(3,1,1);
zplane(b,a);
hold on
plot(p,'^r'); grid
title('Pole-Zero')
hold off
magH = abs(H);
phaH = angle(H);
subplot(3,1,2);
plot(w/pi,magH);grid
xlabel('frequency in pi
units');
ylabel('Magnitude');
title('Magnitude Response')
subplot(3,1,3);
plot(w/pi,phaH/pi);grid
xlabel('frequency in pi
units');
ylabel('Phase in pi
units');
title('Phase Response')
22
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
Practical: 11
Zero/pole/gain:
-10 s (s-2)
----------------------
(s+1)^3 (s^2 + 4s + 5)
To do this, enter:
Z = {[] ; -0.5};
P = {0.3 ; [0.1+i 0.1-i]};
K = [1 ; 2];
H = zpk(Z,P,K,-1); % unspecified sample time
Zero/pole/gain:
(z+0.1) (z+0.2)
---------------
(z+0.3)^2
23
Vishwakarma Government Engineering College
Department of Instrumentation and Control Engineering
Laboratory Manual
Sem: III Subject : Dynamics of Linear Systems (3131705)
4. Create a MIMO zpk model using cell arrays of zeros and poles.
Create the two-input, two-output zero-pole-gain model.
by entering:
H = zpk(Z,P,K);
Use [] as a place holder in Z or P when the corresponding entry of H(s) has no zeros or poles.
24