CNTL 5-20 Report - 2
CNTL 5-20 Report - 2
Code 1:
B=[1 2]’;
C=[3 2];
D=[0];
[num,den]=ss2tf(A,B,C,D)
printsys(num,den,’s’)
Output:
Code 2:
B=[0 1 1]';
C=[1 2 0];
D=[0];
[num,den]=ss2tf(A,B,C,D)
printsys(num,den,'s')
Output:
num=[24];
den=[1 9 26 24];
[A,B,C,D]=tf2ss(num,den)
Output:
Code 2:
num=[30];
den=[1 8 9 6 1 30];
[A,B,C,D]=tf2ss(num,den)
Output:
EXP 6: Determine Pole Zero Location, Values of Natural Frequency and Damping Ratio
Code a:
y=tf([400],[1 12 400])
pzmap(y);
sgrid
[wn,zeta]=damp(y)
Output:
Code b:
y=tf([900],[1 90 900])
pzmap(y)
sgrid
[wn,zeta]=damp(y)
Output:
Code c:
y=tf([225],[1 30 225])
pzmap(y)
sgrid
[wn,zeta]=damp(y)
Output:
Code d:
y=tf([625],[1 0 625])
pzmap(y)
sgrid
[wn,zeta]=damp(y)
Output:
Code 1:
wn=10;
zeta=0.3;
[num0,den]=ord2(wn,zeta)
num=wn^2;
printsys(num,den,'s')
Output:
Code 2:
wn=20;
zeta=0;
[num0,den]=ord2(wn,zeta)
num=wn^2;
printsys(num,den,'s')
Output:
Code 3:
wn=25;
zeta=0.8;
[num0,den]=ord2(wn,zeta)
num=wn^2;
printsys(wn,zeta,'s')
Output:
Code 4:
wn=30;
zeta=1.0;
[num0,den]=ord2(wn,zeta)
num=wn^2;
printsys(num,den,'s')
Output:
EXP 7: Transient and Steady State Responses
Code:
num = 10;
den = [1 2 10];
step(num, den);
title('Step');
impulse(num, den);
title('Impulse');
subplot(3,1,3);
title('Ramp');
Output:
EXP 8: Obtain the Unit-Ramp Response of three transfer functions using ‘lsim’ command
Code:
y1 = lsim(sys1, r, t);
y2 = lsim(sys2, r, t);
y3 = lsim(sys3, r, t);
plot(t, y1);
subplot(3,1,2);
plot(t, y2);
subplot(3,1,3);
plot(t, y3);
Code:
t = 0:0.01:1; % Time vector long enough to show all responses
num1 = [625];
den1 = [1 0 625];
t1 = tf(num1, den1);
subplot(2,2,1)
step(t1, t)
title('Undamped')
num2 = [400];
den2 = [1 12 400];
t2 = tf(num2, den2);
subplot(2,2,2)
step(t2, t)
title('Underdamped')
num3 = [225];
den3 = [1 30 225];
t3 = tf(num3, den3);
subplot(2,2,3)
step(t3, t)
title('Critically Damped')
num4 = [900];
den4 = [1 90 900];
t4 = tf(num4, den4);
subplot(2,2,4)
step(t4, t)
title('Overdamped')
Output:
EXP 10: Show graphically how the change of the damping ratio changes the step response
for single transfer function of constant natural frequency of 1rad/sec.
Code:
num1 = [1];
den1 = [1 0 1];
t1 = tf(num1,den1);
subplot(3,2,1)
step(t1, t)
title('0')
t2 = tf(num2,den2);
subplot(3,2,2)
step(t2, t)
title('0.2')
num3 = [1]; % Transfer function for zeta = 0.4
t3 = tf(num3,den3);
subplot(3,2,3)
step(t3, t)
title('0.4')
t4 = tf(num4,den4);
subplot(3,2,4)
step(t4, t)
title('0.6')
num5 = [1];
t5 = tf(num5,den5);
subplot(3,2,5)
step(t5, t)
title('0.8')
t6 = tf(num6,den6);
subplot(3,2,6)
step(t6, t)
title('1.0')
Output:
EXP 11: Step Response of 2 nd Order system According to Pole Movement.
Code 1:
den1=poly([-1+2i -1-2i]);
den2=poly([-1.5+2i -1.5-2i]);
den3=poly([-2+2i -2-2i]);
num1=den1(3);
num2=den2(3);
num3=den3(3);
f1=tf(num1,den1)
f2=tf(num2,den2)
f3=tf(num3,den3)
pzmap(f1,f2,f3)
t=0:0.1:10;
c1=step(num1,den1,t);
c2=step(num2,den2,t);
c3=step(num3,den3,t);
plot(t,c1,t,c2,t,c3)
Output:
Code 2:
den1=poly([-1+2i -1-2i]);
den2=poly([-1+4i -1-4i]);
den3=poly([-1+6i -1-6i]);
num1=den1(3);
num2=den2(3);
num3=den3(3);
f1=tf(num1,den1)
f2=tf(num2,den2)
f3=tf(num3,den3)
pzmap(f1,f2,f3)
t=0:0.1:10;
c1=step(num1,den1,t);
c2=step(num2,den2,t);
c3=step(num3,den3,t);
plot(t,c1,t,c2,t,c3)
Output:
Code 3:
den1=poly([-1+2i -1-2i]);
den2=poly([-2+4i -2-4i]);
den3=poly([-3+6i -3-6i]);
num1=den1(3);
num2=den2(3);
num3=den3(3);
f1=tf(num1,den1)
f2=tf(num2,den2)
f3=tf(num3,den3)
pzmap(f1,f2,f3)
t=0:0.1:10;
c1=step(num1,den1,t);
c2=step(num2,den2,t);
c3=step(num3,den3,t);
plot(t,c1,t,c2,t,c3)
Output:
Code:
m = 5; % mass (kg)
num = 1;
den = [m b k];
sys = tf(num,den);
info = stepinfo(sys);
% Display
Output:
EXP 13: Second Order Approximation
Code:
num = [1];
den = [1 2 10]; % Example: wn=√10, zeta=0.316
Output:
EXP 14: Reduction of Multiple Subsystems
Code 1:
numg=[1 1];
deng=[500 0 0];
numh=[1 1];
denh=[1 2];
[num,den]=feedback(numg,deng,numh,denh,-1);
printsys(num,den)
Output 1:
Code 2:
% Define G(s)
% Define Gc(s)
% Display result
printsys(num, den)
Output:
Code 3
Output
Code:
num=1000*[1 8];
den=poly([-7 -9]);
G=tf(num,den);
kp=dcgain(G)
estep=1/(1+kp)
Output:
rlocus(G);
% Plot root locus with a damping ratio line (for example: zeta = 0.5)
zeta=0.5; % Damping ratio
Output:
EXP 17: Frequency Response Analysis
Code a:
G = 10 / (s * (s + 1) * (s + 2));
bode(G)
Output:
Code b:
bode(G)
Output:
Code c:
G = 50 * (s + 3) / ((s + 2) * (s + 4));
bode(G)
Output:
Q: Determine the Gain Margin, Phase Margin, Gain Crossover Frequency, phase crossover
frequency of any transfer function using both figure and margin command.
Code:
figure;
% Convert to dB
GM_dB = 20 * log10(GM);
Output:
Code a:
b=[0;25];
c=[1 0];
d=[0];
bode(a,b,c,d)
Output:
EXP 18: Routh-Hurwitz Criterion for Stability
Question
Code:
r2 = [a2, a0];
% Optional: Find intersection of intervals manually fplot(r3_1, [0, 10]); grid on; xlabel('K');
ylabel('Routh Row 3 Value'); title('Routh Criterion Condition for Stability');
Output:
EXP 19: Improvement of a system using PID Controller
Question:
Code:
Output: