CNTL 5-20 Report - 3
CNTL 5-20 Report - 3
Submitted to
Kulsuma Khanum
Lecturer
Department of Electrical and Electronics Engineering
Leading University, Sylhet.
Submitted By
Md. Abdul Malek Fahim
ID: 0182220012131004
Batch: 36
Department of Electrical and Electronics Engineering
Leading University, Sylhet
To convert a system from state-space representation to transfer function form and vice
versa using MATLAB.
Theory:
State-space and transfer function models are two main ways to represent linear time-
invariant (LTI) systems. The state-space model is especially useful for multiple-input
multiple-output (MIMO) systems and modern control design. The transfer function
provides a frequency domain representation of the system, ideal for analysis of stability
and transient behavior.
MATLAB provides ss2tf() for state-space to transfer function conversion, and tf2ss()
for the reverse.
Code 1:
C=[3 2];
D=[0];
[num,den]=ss2tf(A,B,C,D)
printsys(num,den,’s’)
Output:
Code 2:
A=[0 2 3;0 6 5;1 4 2];
B=[0 1 1]';
C=[1 2 0];
D=[0];
[num,den]=ss2tf(A,B,C,D)
printsys(num,den,'s')
Output:
Transfer Function to State Space
Code 1:
num=[100];
den=[1 20 10 7 100];
[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:
Discussion:
This experiment is fundamental in control systems as it bridges the gap between classical
and modern control approaches. In Electrical Engineering, these concepts are crucial in:
Being able to switch between representations helps in both simulation and real-time
implementation of control systems.
Experiment 6: Determine Pole Zero Location, Values of
Natural Frequency and Damping Ratio
Objective:
To analyze second-order systems using pole-zero plots, and to determine the natural
frequency () and damping ratio () using MATLAB.
Theory:
The damping ratio and natural frequency are parameters that determine the transient
response of a system. MATLAB functions pzmap() and damp() are used to visualize and
compute these parameters. These properties help classify the system as underdamped,
overdamped, critically damped, or undamped.
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:
Discussion:
To analyze the step, impulse, and ramp responses of a second-order system using
MATLAB.
Theory:
Code:
num = 10;
den = [1 2 10];
step(num, den);
title('Step');
impulse(num, den);
title('Impulse');
% Unit Ramp Response
subplot(3,1,3);
title('Ramp');
Output:
Discussion:
To simulate ramp input response for different transfer functions using lsim().
Theory:
The lsim() function simulates time response to arbitrary inputs such as ramps. It helps in
understanding how systems handle slowly changing signals.
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);
Discussion:
Simulating unit-ramp responses is critical in systems that require constant tracking, such
as servomechanisms, antenna positioning systems, or elevator controllers. Electrical
Engineers often design controllers to minimize the error between actual and desired
positions or speeds over time. By using the lsim function, engineers gain practical insight
into how systems respond to linear inputs, allowing them to assess lag, steady-state error,
and response time in real applications involving continuous control and regulation.
Theory:
Step response varies significantly with damping. MATLAB enables simulation using
second-order transfer functions to classify systems.
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:
Discussion:
To study how varying damping ratios affect the system's step response.
Theory:
Damping ratio affects overshoot, rise time, and settling time. This helps in choosing proper
damping for performance tuning.
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')
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')
num6 = [1];
t6 = tf(num6,den6);
subplot(3,2,6)
step(t6, t)
title('1.0')
Output:
Discussion:
The damping ratio directly influences how a system reacts to sudden changes, making it a
key consideration in fields like renewable energy systems, electric vehicle control, and
industrial drives. By studying how varying the damping ratio alters the step response,
Electrical Engineers can design systems that are not only stable but also responsive and
energy-efficient. This experiment provides foundational insight for optimizing performance
and avoiding issues like excessive overshoot or sluggish behavior in practical control
systems.
Experiment 11: Step Response of 2nd Order System
According to Pole Movement
Objective:
To analyze how changes in the location of poles affect the step response of second-order
systems.
Theory:
Pole locations in the s-plane significantly impact the time response of a system. Systems
with poles farther to the left are faster and more stable. This experiment explores systems
with complex conjugate poles with varying real parts.
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:
Discussion:
This experiment is important for understanding how system poles influence time-domain
performance like speed and damping. In control design and power electronics, many
systems require precise tuning of transient characteristics. For instance, motor drives and
compensators for inverter systems often rely on pole placement analysis to balance
stability and responsiveness. Knowledge of how pole manipulation affects step response
supports the design of more reliable and optimized control systems.
Objective:
Theory:
Underdamped systems exhibit oscillations before settling. Parameters like rise time, peak
time, overshoot, and settling time define system performance.
Code:
m = 5; % mass (kg)
num = 1;
den = [m b k];
sys = tf(num,den);
info = stepinfo(sys);
% Display
Output:
Discussion:
Objective:
To understand the impact of far poles and zeros on the second-order approximation.
Theory:
Code:
num = [1];
Output:
Discussion:
To simplify block diagrams with series and feedback systems using MATLAB.
Theory:
Combining multiple blocks into one system using convolution and feedback functions
helps in analyzing and designing complete control systems.
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
Discussion:
Code:
num=1000*[1 8];
den=poly([-7 -9]);
G=tf(num,den);
kp=dcgain(G)
estep=1/(1+kp)
Output:
Discussion:
To plot the root locus of a system and observe how poles change with gain.
Theory:
Root locus shows the path of poles as gain varies. It is used in controller design for system
stability.
Code:
rlocus(G);
% Plot root locus with a damping ratio line (for example: zeta = 0.5)
zeta=0.5; % Damping ratio
Output:
Discussion:
Root locus is a valuable tool for control system design, particularly in tuning controllers to
meet stability and transient performance requirements. In areas such as voltage
regulation, motor drive control, and industrial automation, visualizing pole migration with
gain variation aids in selecting appropriate controller gains. This experiment builds the
foundation for using root locus to enhance system responsiveness and reliability.
Frequency response provides insights into gain and phase margins. Bode plots help in
stability and performance 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:
a=[0 1;-25 -4];
b=[0;25];
c=[1 0];
d=[0];
bode(a,b,c,d)
Output:
Discussion:
Frequency response analysis is vital in disciplines such as analog circuit design, power
systems, and communications. This experiment provides experience with Bode plots and
the interpretation of gain and phase margins. These concepts are essential when designing
stable filters, amplifiers, and feedback systems, and are widely applied to validate the
robustness and performance of electrical systems in varying frequency environments.
Experiment 18: Routh-Hurwitz Criterion for Stability
Objective:
To determine the range of gain K for which a system remains stable using Routh-Hurwitz
criterion.
Theory:
The Routh-Hurwitz criterion provides a method to determine the number of right-half plane
poles without solving the equation. It is fundamental in control system stability analysis.
Question
Code:
r1 = [a3, a1];
r2 = [a2, a0];
Output:
Discussion:
Objective:
To observe the performance improvement of a system using P, PI, PD, and PID controllers.
Theory:
PID controllers combine proportional, integral, and derivative actions to improve transient
and steady-state behavior.
Question:
Code:
Output:
Discussion:
Understanding pole-zero locations and system characteristics like damping ratio and
natural frequency is crucial in fields such as power electronics, motor control, and filter
design. In an Electrical Engineering job, this knowledge allows professionals to predict how
systems will behave under different conditions. For example, in designing a servo motor
system or tuning a power converter, engineers must know how to shape the transient
response. Using MATLAB tools to analyze these parameters speeds up design cycles and
enhances accuracy in real-world applications.