Experiment-1: AIM: For The Given Train Model, Find The State Space Model
Experiment-1: AIM: For The Given Train Model, Find The State Space Model
Experiment-1: AIM: For The Given Train Model, Find The State Space Model
AIM: For the given train model , find the state space model.
THEORY:
State Variables
The internal state variables are the smallest possible subset of system variables that can
represent the entire state of the system at any given time. The minimum number of state
variables required to represent a given system, is usually equal to the order of the system's
defining differential equation. If the system is represented in transfer function form, the
minimum number of state variables is equal to the order of the transfer function's
denominator after it has been reduced to a proper fraction. It is important to understand that
converting a state-space realization to a transfer function form may lose some internal
information about the system, and may provide a description of a system which is stable,
when the state-space realization is unstable at certain points. In electric circuits, the number
of state variables is often, though not always, the same as the number of energy storage
elements in the circuit such as capacitors and inductors. The state variables defined must be
linearly independent, i.e., no state variable can be written as a linear combination of the other
state variables or the system will not be able to be solved.
PROGRAM:
clear all;
close all;
M1 = 1;
M2 = 0.5;
k = 1;
u = 0.002;
F =1;
g =9.8;
num = [M2 M2*g*u 1]
den = [M1*M2 2*M1*M2*u*g M1*k+M1*M2*u*u*g*g+M2*k M1*k*u*g+M2*k*u*g]
[A,B,C,D]=tf2ss(num,den)
OUTPUT:
EXPERIMENT- 2
Aim: For the given transfer model, obtain state space and also determine observability and
controllability.
25
2𝑠 + 1 + 𝑆 2
Theory:
A system is said to be controllable at time t0 if it is possible by means of an unconstrained
control vector to transfer the system from any initial state to any other state in a finite
interval of time
Controllability depends upon the system matrix A and the control influence matrix B
Cb ≜ [𝐵 𝐴𝐵 𝐴2 𝐵 … … … … . 𝐴𝑛−1 𝐵]
A system is said to be observable at time t0 if, with the system in state X(t0) ,it is
possible to determine this state from the observation of the output over a finite
interval of time
Observability depends upon the system matrix A and the output matrix C
Program:
clc;
clear all;
close all;
A = [-1 0 0; 0 -2 0; 0 0 -3];
B = [1; 0; 0];
C = [1 0 2];
D = [0];
m = ctrb(A,B)
rank_of_m = rank(m)
n = obsv(A,C)
rank_of_n = rank(n)
system_order = length(A)
if rank(m) == system_order
display('This system is controllable')
else
display('This system is not controllable')
end
if rank(n) == system_order
display('This system is observable')
else
display('This system is not observable')
end
Output:
m=
1 -1 1
0 0 0
0 0 0
rank_of_m =
1
n=
1 0 2
-1 0 -6
1 0 18
rank_of_n =
2
system_order = 3
This system is not controllable
This system is not observable
EXPERIMENT- 3
Aim: SISO system is given by
−1 0 0 1
ẋ = [ 0 −2 0 ] x(t) + [0] u(t)
0 0 −3 0
y = [1 0 2] x(t)
Theory:
SISO is an acronym for single-input and single-output system. In control engineering it
usually refers to a simple single variable control system with one input and one output. In
radio it is the use of only one antenna both in the transmitter and receiver.
SISO systems are typically less complex than multiple-input multiple-output (MIMO)
systems. Usually, it is also easier to make order of magnitude or trending predictions "on the
fly" or "back of the envelope". MIMO systems have too many interactions for most of us to
trace through them quickly, thoroughly, and effectively in our heads.
Frequency domain techniques for analysis and controller design dominate SISO control
system theory. Bode, Nyquist, Nichols, and root locus are the usual tools for SISO system
analysis. Controllers can be designed through the polynomial design, root locus design
methods to name just 2 of the more popular. Often SISO controllers will be PI, PID, or lead-
lag.
Program:
clc;
clear all;
close all;
A = [-1 0 0; 0 -2 0; 0 0 -3];
B = [1; 0; 0];
C = [1 0 2];
D = [0];
m = ctrb(A,B)
rank_of_m = rank(m)
n = obsv(A,C)
rank_of_n = rank(n)
system_order = length(A)
if rank(m) == system_order
display('This system is controllable')
else
display('This system is not controllable')
end
if rank(n) == system_order
display('This system is observable')
else
display('This system is not observable')
end
Output:
m=
1 -1 1
0 0 0
0 0 0
rank_of_m =
1
n=
1 0 2
-1 0 -6
1 0 18
rank_of_n =
2
system_order =
3
0 1 0 0
ẋ = [ 0 0 1 ] x + [ 25 ] u
−5 −25 −5 −120
y = [1 0 0] x
Draw impulse, step and ramp response of the system. Also draw bode and nyquist plot of the
system.
Theory:
In signal processing, the impulse response, or impulse response function (IRF), of
a dynamic system is its output when presented with a brief input signal, called an impulse.
More generally, an impulse response refers to the reaction of any dynamic system in response
to some external change. In both cases, the impulse response describes the reaction of the
system as a function of time (or possibly as a function of some other independent
variable that parameterizes the dynamic behavior of the system).
For example, the dynamic system might be a planetary system in orbit around a star; the
external influence in this case might be another massive object arriving from elsewhere in the
galaxy; the impulse response is the change in the motion of the planetary system caused by
interaction with the new object.
In all these cases, the 'dynamic system' and its 'impulse response' may refer to actual physical
objects, or to a mathematical system of equations describing these objects.
The step response of a system in a given initial state consists of the time evolution of its
outputs when its control inputs are Heaviside step functions. In electronic
engineering and control theory, step response is the time behaviour of the outputs of a
general system when its inputs change from zero to one in a very short time. The concept can
be extended to the abstract mathematical notion of a dynamical system using anevolution
parameter.
From a practical standpoint, knowing how the system responds to a sudden input is important
because large and possibly fast deviations from the long term steady state may have extreme
effects on the component itself and on other portions of the overall system dependent on this
component. In addition, the overall system cannot act until the component's output settles
down to some vicinity of its final state, delaying the overall system response. Formally,
knowing the step response of a dynamical system gives information on the stability of such a
system, and on its ability to reach one stationary state when starting from another.
Program:
clc;
clear all;
close all;
A = [0 1 0 ; 0 0 1 ; -5 -25 -5];
B = [0;25;-120];
C = [1 0 0];
D = [0];
[num,den] = ss2tf(A,B,C,D)
t = tf(num,den)
subplot(311)
step(t)
subplot(312)
impulse(t)
t1 = tf([1],[1 0])
t2 = t*t1
subplot(313)
step(t2)
subplot(211)
bode(t)
subplot(212)
nyquist(t)
Output:
num =
0 0.0000 25.0000 5.0000
den =
1.0000 5.0000 25.0000 5.0000
Transfer function:
8.882e-015 s^2 + 25 s + 5
-------------------------
s^3 + 5 s^2 + 25 s + 5
Transfer function:
1
-
s
Transfer function:
8.882e-015 s^2 + 25 s + 5
--------------------------
s^4 + 5 s^3 + 25 s^2 + 5 s
Bode Diagram
Phase (deg) Magnitude (dB)
100
-100
0
-90
-180
-1 0 1 2
10 10 10 10
Frequency (rad/sec)
Nyquist Diagram
2
1
Imaginary Axis
-1
-2
-1 -0.5 0 0.5 1 1.5
Real Axis
EXPERIMENT- 5
Aim: For a given state space model of a magnetically suspended ball, write MATLAB code
to find poles of matrix A. State whether system is stable or not. Plot output of system for step
input.
1 0 1 0
A = [980 0 −2.8 ] B=[ 0 ]
0 0 −100 100
C = [1 1 1] D = [0]
Program:
clc;
clear all;
close all;
A = [1 0 1 ; 980 0 -2.8 ; 0 0 -100];
B = [0 ; 0 ; 100];
C = [1 1 1];
D = [0];
poles_sys = eig(A)
if poles_sys < 0
display('This system is stable.')
else
display('This system is not stable.')
end
[num,den] = ss2tf(A,B,C,D);
t = tf(num,den);
step(t)
Output:
poles_sys =
0
1
-100
2.5
2
Amplitude
1.5
0.5
0
0 5 10 15
Time (sec)
EXPERIMENT- 6
Aim: Find the transfer function, impulse response, step response, ramp response, pole zero
map, bode plot and nyquist plot of following diagrams using
1. MATLAB
2. SIMULINK
(a)
s2 +2s+1 1
s3 +4 s2 + 3s +1 s+4
(b)
𝑠 2 + 2s + 1
𝑠 3 + 4 𝑠 2 + 3s + 1
1
s+4
(c)
𝑠 2 + 2s + 1
𝑠 3 + 4 𝑠 2 + 3s + 1
1
s+4
Theory:
Pole–Zero Plot
In mathematics, signal processing and control theory, a pole–zero plot is a graphical
representation of a rational transfer function in the complex plane which helps to convey
certain properties of the system such as:
Stability
Causal system / anticausal system
Region of convergence (ROC)
Minimum phase / non minimum phase
In general, a rational transfer function for a discrete LTI system has the form:
where
Program:
clc;
clear all;
close all;
t1 = tf([1 2 1],[1 4 3 1])
t2 = tf([1],[1 4])
t3 = tf([1],[1 0])
display('transfer function of series system:')
ts = series(t1,t2)
display('transfer function of parallel system:')
tp = parallel(t1,t2)
display('transfer function of feedback system:')
tf = feedback(t1,t2)
figure(1)
subplot(611)
step(ts)
title('step response of series system')
subplot(612)
impulse(ts)
title('impulse response of series system')
subplot(613)
step(t3*ts)
title('ramp response of series system')
subplot(614)
bode(ts)
title('bode plot of series system')
subplot(615)
nyquist(ts)
title('nyquist plot of series system')
subplot(616)
pzmap(ts)
title('pole zero map of series system')
figure(2)
subplot(611)
step(tp)
title('step response of parallel system')
subplot(612)
impulse(tp)
title('impulse response of parallel system')
subplot(613)
step(t3*tp)
title('ramp response of parallel system')
subplot(614)
bode(tp)
title('bode plot of parallel system')
subplot(615)
nyquist(tp)
title('nyquist plot of parallel system')
subplot(616)
pzmap(tp)
title('pole zero map of parallel system')
figure(3)
subplot(611)
step(tf)
title('step response of feedback system')
subplot(612)
impulse(tf)
title('impulse response of feedback system')
subplot(613)
step(t3*tf)
title('ramp response of feedback system')
subplot(614)
bode(tf)
title('bode plot of feedback system')
subplot(615)
nyquist(tf)
title('nyquist plot of feedback system')
subplot(616)
pzmap(tf)
title('pole zero map of feedback system')
Output:
Transfer function:
s^2 + 2 s + 1
---------------------
s^3 + 4 s^2 + 3 s + 1
Transfer function:
1
-----
s+4
Transfer function:
1
-
s
Transfer function:
s^2 + 2 s + 1
-------------------------------
s^4 + 8 s^3 + 19 s^2 + 13 s + 4
Transfer function:
2 s^3 + 10 s^2 + 12 s + 5
-------------------------------
s^4 + 8 s^3 + 19 s^2 + 13 s + 4
Transfer function:
s^3 + 6 s^2 + 9 s + 4
-------------------------------
s^4 + 8 s^3 + 20 s^2 + 15 s + 5
Amplitude step response of series system
0.4
0.2
0
0 2 4 6 8 10 12 14
impulse response of series system
Time (sec)
Amplitude
0.2
0
-0.2
0 2 4 6 8 10 12 14
ramp response of series
Time (sec) system
Amplitude
400
200
0
Imaginary AxisMagnitude (dB)
-500
-100
-2 -1 0 1 2
10 10 10 10 10
nyquist plot of series system
0.2 Frequency (rad/sec)
0
-0.2
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4
Imaginary Axis
Amplitude
2
1
0
0 2 4 6 8 10 12
impulse response of parallel system
Time (sec)
Amplitude
2
0
-2
0 1 2 3 4 5 6 7 8 9
ramp response of parallel
Time (sec) system
Amplitude
2000
1000
0
Imaginary AxisMagnitude (dB)
50
0
-50
-2 -1 0 1 2
10 10 10 10 10
nyquist plot of parallel system
1 Frequency (rad/sec)
0
-1
-1 -0.5 0 0.5 1 1.5
Imaginary Axis
1
0.5
0
0 5 10 15
impulse response of feedback
Time (sec) system
Amplitude
1
0
-1
0 5 10 15
ramp response of feedback
Time (sec) system
Amplitude
2000
1000
0
(deg) (dB)
-2 -1 0 1 2
10 10 10 10 10
Imaginary Axis
2s + 4
𝑠2 + 2
2s + 1 s+1
3s + 2 s+2
2s + 9
𝑠 3 + 4 𝑠 2 + 3s + 1
3s + 2
𝑠 2 + 2s + 1
s + 10
5s + 2
Theory:
Pole–Zero Plot
In mathematics, signal processing and control theory, a pole–zero plot is a graphical
representation of a rational transfer function in the complex plane which helps to convey
certain properties of the system such as:
Stability
Causal system / anticausal system
Region of convergence (ROC)
Minimum phase / non minimum phase
In general, a rational transfer function for a discrete LTI system has the form:
where
Program:
clc;
clear all;
close all;
t1 = tf([2 1],[3 2]);
t2 = tf([1 1],[1 2]);
t4 = tf([2 4],[1 0 2]);
t3 = tf([2 9],[1 5]);
t5 = tf([3 2],[1 2 1]);
t6 = tf([1 10],[5 2]);
t7 = parallel(t3,t4)
t8 = feedback(t5,t6)
t9 = series(t1,t2)
t10 = series(t9,t7)
t13 = tf([1],[1 0])
display('the final transfer function is :')
t11 = feedback(t10,t8)
t12 = series(t11,t13)
subplot(611)
step(t11)
subplot(612)
impulse(t11)
subplot(613)
step(t12)
subplot(614)
bode(t11)
subplot(615)
nyquist(t11)
subplot(616)
pzmap(t11)
Output:
Transfer function:
2 s^3 + 11 s^2 + 18 s + 38
--------------------------
s^3 + 5 s^2 + 2 s + 10
Transfer function:
15 s^2 + 16 s + 4
--------------------------
5 s^3 + 15 s^2 + 41 s + 22
Transfer function:
2 s^2 + 3 s + 1
---------------
3 s^2 + 8 s + 4
Transfer function:
4 s^5 + 28 s^4 + 71 s^3 + 141 s^2 + 132 s + 38
----------------------------------------------
3 s^5 + 23 s^4 + 50 s^3 + 66 s^2 + 88 s + 40
Transfer function:
1
-
s
Transfer function:
20 s^8 + 200 s^7 + 939 s^6 + 3006 s^5 + 6302 s^4 + 9513 s^3 + 9084 s^2 + 4462 s + 836
-----------------------------------------------------------------------
15 s^8 + 220 s^7 + 1202 s^6 + 3618 s^5 + 7349 s^4 + 9846 s^3 + 8906 s^2 + 4712 s + 1032
Transfer function:
20 s^8 + 200 s^7 + 939 s^6 + 3006 s^5 + 6302 s^4 + 9513 s^3 + 9084 s^2 + 4462 s + 836
---------------------------------------------------------------------
15 s^9 + 220 s^8 + 1202 s^7 + 3618 s^6 + 7349 s^5 + 9846 s^4 + 8906 s^3 + 4712 s^2 +
1032 s
Step Response
Amplitude 1.5
1
0.5
0 2 4 6 8 10 12
Impulse
TimeResponse
(sec)
Amplitude
10
0
-10
0 1 2 3 4 5 6 7 8 9
Step Response
Time (sec)
Amplitude
2000
1000
0
Imaginary AxisMagnitude (dB)
10
-100
-2 -1 0 1 2
10 10 10 10 10
Nyquist Diagram
1 Frequency (rad/sec)
0
-1
-1 -0.5 0 0.5 1 1.5
Imaginary Axis
Pole-Zero Map
Real Axis
5
0
-5
-7 -6 -5 -4 -3 -2 -1 0
Real Axis
EXPERIMENT- 8
Aim: Calculate following fuzzy sets:
A union B, A intersection B, complement A, complement B where
Theory:
Fuzzy Logic
As an extension of the case of multi-valued logic, valuations ( )
of propositional variables ( ) into a set of membership degrees ( ) can be thought of
as membership functions mapping predicates into fuzzy sets (or more formally, into an
ordered set of fuzzy pairs, called a fuzzy relation). With these valuations, many-valued logic
can be extended to allow for fuzzy premises from which graded conclusions may be drawn.
This extension is sometimes called "fuzzy logic in the narrow sense" as opposed to "fuzzy
logic in the wider sense," which originated in the engineering fields of automated control
and knowledge engineering, and which encompasses many topics involving fuzzy sets and
"approximated reasoning."
Industrial applications of fuzzy sets in the context of "fuzzy logic in the wider sense" can be
found at fuzzy logic.
Fuzzy sets
Fuzzy sets are sets whose elements have degrees of membership. Fuzzy sets were introduced
simultaneously[1] by Lotfi A. Zadeh and Dieter Klaua in 1965 as an extension of the classical
notion of set. In classical set theory, the membership of elements in a set is assessed in binary
terms according to a bivalent condition — an element either belongs or does not belong to the
set. By contrast, fuzzy set theory permits the gradual assessment of the membership of
elements in a set; this is described with the aid of a membership function valued in the real
unit interval [0, 1]. Fuzzy sets generalize classical sets, since the indicator functions of
classical sets are special cases of the membership functions of fuzzy sets, if the latter only
take values 0 or 1. In fuzzy set theory, classical bivalent sets are usually called crisp sets. The
fuzzy set theory can be used in a wide range of domains in which information is incomplete
or imprecise, such as bioinformatics.
Program:
clc;
clear all;
close all;
A = [1 0.4 0.6 0.3];
B = [0.3 0.2 0.6 0.5];
for i=1:4
union(i) = max(A(i),B(i));
intersection(i) = min(A(i),B(i));
comp_A(i) = 1-A(i);
comp_B(i) = 1-B(i);
end
disp('A union B');
union
disp('A intersection B');
intersection
disp('Complement A');
comp_A
disp('Complement B');
comp_B
Output:
A union B
union =
1.0000 0.4000 0.6000 0.5000
A intersection B
intersection =
0.3000 0.2000 0.6000 0.3000
Complement A
comp_A =
0 0.6000 0.4000 0.7000
Complement B
comp_B =
Program:
clc;
clear all;
close all;
Wn = 1;
z = 0:0.2:1;
t = 0:0.2:10;
x = zeros(51,6);
figure(1)
for i = 1:6
[num,den] = ord2(Wn,z(i));
sys = tf(num,den);
step(sys,t)
hold on
end;
text(3, 1.8, 'zeta = 0');
text(3, 1.5, 'zeta = 0.2');
text(4, 1.2, 'zeta = 0.4');
text(4, 1.1, 'zeta = 0.6');
text(4, 1.0, 'zeta = 0.8');
text(5, 0.9, 'zeta = 1');
figure(2)
for i = 1:6
[num,den] = ord2(Wn,z(i));
sys = tf(num,den);
[y,t] = step(sys,t);
x(:,i) = y;
plot(t,y);
hold on;
end
figure(3)
mesh(t,z,x');
Output:
Step Response
2
1.8 zeta = 0
1.6
zeta = 0.2
1.4
1 zeta = 0.8
zeta = 1
0.8
0.6
0.4
0.2
0
0 1 2 3 4 5 6 7 8 9 10
Time (sec)
1.8
1.6
1.4
1.2
0.8
0.6
0.4
0.2
0
0 1 2 3 4 5 6 7 8 9 10
2
1.5
0.5
0
1
10
8
0.5 6
4
2
0 0
Step Response
1.4
1.2
0.8
Amplitude
0.6
0.4
0.2
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time (sec)