Cycle - II Experiments
Cycle - II Experiments
No: Date:
APPARATU REQUIRED
1. A PC with MATLAB package.
THEORY
State Variable approach is a more general mathematical representation of a system, which, along with
the output, yields information about the state of the system variables at some predetermined points along
the flow of signals. It is a direct time-domain approach, which provides a basis for modern control theory
and system optimization. SISO (single input single output) linear systems can be easily defined with
transfer function analysis. The transfer function approach can be linked easily with the state variable
approach.
The state model of a linear-time invariant system is given by the following equations:
Ẋ (t) = A X(t) + B U(t) State equation
Y(t) = C X(t) + D U(t) Output equation
Where A = n x n system matrix, B = n x m input matrix,
C= p x n output matrix and
D = p x m transmission matrix,
2. Impulse Input Open Loop –I Order
Impulse Response
4
3.5
2.5
Amplitude
2
1.5
0.5
0
0 0.5 1 1.5 2 2.5 3
Time (sec)
PROGRAM:
B. Close Loop Response
1. Response of Step input
n=[4];
d=[1 2];
sys=tf(n,d);
sys=feedback(sys,1,-1)
step(sys)
2. Response of Impulse input
n=[4];
d=[1 2];
sys=tf(n,d);
sys=feedback(sys,1,-1)
impulse(sys)
Simulink Model
1. Step Input Close Loop –I Order
Step Response
0.7
0.6
System: sys
Time (sec): 0.192
0.5 Amplitude: 0.456
0.4
Amplitude
0.3
0.2
0.1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time (sec)
Impulse Response
4
3.5
2.5
Amplitude
1.5
0.5
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time (sec)
Step Response
0.35
0.3
0.25
0.2
Amplitude
0.15
0.1
0.05
0
0 0.5 1 1.5 2 2.5
Time (sec)
Impulse Response
0.45
0.4
0.35
0.3
0.25
Amplitude
0.2
0.15
0.1
0.05
-0.05
0 0.5 1 1.5 2 2.5 3
Time (sec)
Close Loop Response
1. Step Input
n=[4];
d=[1 6 16];
sys=tf(n,d);
sys=feedback(sys,1,-1) ;
step(sys)
2. Impulse Input
n=[4];
d=[1 6 16];
sys=tf(n,d);
sys=feedback(sys,1,-1) ;
impulse(sys)
Simulink Model
1. Step Input Close Loop –II Order
Step Response
0.25
0.2
0.15
Amplitude
0.1
0.05
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8
Time (sec)
2. Impulse Input Close Loop –II Order
Impulse Response
0.45
0.4
0.35
0.3
0.25
Amplitude
0.2
0.15
0.1
0.05
-0.05
0 0.5 1 1.5 2 2.5
Time (sec)
RESULT
Thus the digital simulation of time response characteristics of a first and second order linear system with
step and impulse inputs were simulated using MATLAB and outputs are observed for respective inputs.
PROGRAM:
syms p(t) m(t) l(t) T Y
Eqns = [diff(p(t),t) == (3*p(t)*(1-p(t)))-(30*(p(t)*m(t))); diff(m(t),t) == ((25*p(t)+l(t))*m(t)*(1-m(t)))-
m(t); diff(l(t),t) == (15*(1+tanh(2*m(t)-2)))-l(t)]
[DEsys,Subs] = odeToVectorField(Eqns);
DEFcn = matlabFunction(DEsys, 'Vars',{T,Y});
tspan = [0,25];
y0 = [0.01 0.05 0.539];
grid
Expt. No: Date:
APPARATU REQUIRED
1. A PC with MATLAB package.
THEORY
An ordinary differential equation (ODE) is an equation that involves derivatives of an unknown function.
Ordinary differential equations are used to model changeover a single independent variable (it is usually
t for time). These equations do not involve any partial derivatives. Differential equations contain three
types of variables: an independent variable, at least one dependent variable (these will be functions of
the independent variable), and the parameters. ODE’s can contain multiple iterations of derivatives and
are named accordingly (i.e. if there are only first derivatives, then the ODE is called a first order ODE).
RESULT
Thus the digital simulation of time response characteristics of a nonlinear differential equations were
simulated using MATLAB and outputs are observed for respective inputs.
PROGRAM
1. First Order Differential Equation
function dy = f(t,y)
dy = -2*y + (t>=0)-(t>=1);
t= [0 5];
inity=0;
[t,y]=ode45(@f, t, inity);
plot(t,y)
dz=[-3*z(1)-2*z(2)+cos(2*t); z(1)];
t=[0 10];
initz=[1; 0];
[t,z]=ode45(@f2, t, initz);
plot(t, z(:,2))
Expt. No: Date:
APPARATUS:
S.no Software
1. MATLAB
2. Simulink
FORMULA:
The corresponding differential equations are as follows:
BLOCK DIAGRAM/CODE:
1. Code:
>>num=[5 5 11];
>>den=[25 40 91 27 30];
>>G=tf(num,den);
>>kp=dcgain(G);
>>ess=1/(1+kp);
>>step(G);
2. Simulink model:
OBSERVATIONS:
1. Code:
num = 5 5 11
den = 25 40 91 27 30
G=
5 s^2 + 5 s + 11
--- - - - - -
ess = 0.7317
2. Simulink:
MEASUREMENTS VALUES
60.484%
Overshoot
0.806
Preshoot
5.563
Undershoot
1.8585 seconds
Rise Time
1.848 seconds
Fall Time
45.5 seconds
Settling Time
0.347
Final Value
0.7317
Steady state Error
INFERENCE:
The differential equations for a linear mechanical system were established and itwas realized using
Simulink.
The corresponding transfer function graph was plotted for step input, in Simulinkand MATLAB,
and the properties were analyzed.
The damping effect of the spring system was established, and the correspondingdata was tabulated.
RESULT:
Thus, the mathematical model of the linear mechanical system was simulated, and the corresponding
parameters were noted.
b. ELECTRICAL SYSTEM
AIM
To design and simulate a mathematical model for a series RLC electrical circuitand analyze the
response graph.
APPARATUS
S.no Software
1. MATLAB
2. Simulink
BLOCK DIAGRAM/CODE:
>>R=3;
>>L=1;
>>C=0.05;
>>num=[1./L];
>>den=[1 (R/L) 1./(L*C) ];
>>G=tf(num,den);
>>step(G);
OBSERVATIONS:
1. MATLAB code:
2. Simulink:
MEASUREMENTS VALUES
30.921%
Overshoot
0.658%
Pre shoot
9.302%
Undershoot
317.030 ms
Rise Time
RESULT
Thus, for a series RLC electrical circuit, the transfer function was obtained, and the corresponding
Simulink model and MATLAB codewas designed. For a step input, the resultant graph was plotted
andanalyzed.
BLOCK DIAGRAM:
1. Simulink model:
OBSERVATIONS:
1. Simulink:
Process A:
Process B:
20
APPARATUS REQUIRED
PROCEDURE
1. Open the mat lab command window from the start up or from the short cut
2. Type edit to open the tool box
3. Create the new file
4. Write the program file
5. Save the program and run it
6. Observe the wave form and verify the output with the theoretical values
PROGRAM
Pole-Zero Map
Routh-Hurwitz Criterion
G(s) = S3+S2+2S+24 = 0
>>numg=[1]; deng=[1 1 2 23];
>>[num,den]=cloop(num,deng);
>>roots(den) ans=
-3.0000
1.0000+2.
6458i
1.0000-2.6458i
Unstable Roots
RESULT
Thus the pole zero maps and Routh Hurwitz Criterion was analyzed using MATLAB software.
22
AIM
To test the controllability and observability of a given system in both s and zdomain using
MATLAB.
APPARATUS:
S.no Software
1. MATLAB
FORMULA/THEORY:
Controllability and observability are two important properties of state models which are
integral to the designing of a controller. These two properties suggestwhat modifications
should be made to the plant (actuators and sensors) so thatthe desired action is achieved.
Controllability deals with the possibility of forcing the system to a particular stateby
application of a control input. More formally, if a state is controllable, it meansthat there
exist some control signals that allow the system to reach any state in afinite amount of time.
Phase (deg)
It is impractical to know all the states of a system. So, sometimes it is limited tothe critical
states. Thus, if a state is not observable then the controller will not be able to determine its
behavior from the system output and hence not be able to use that state to stabilize the
system.
23
Controllability:
The state equation (or the pair (A, B)) is said to be completely state controllable or
simply state controllable if for any initial state x(0) and any final state x(N), there
exists an input sequence u(k), k = 0, 1, 2, · · · , N, whichtransfers x(0) to x(N) for
some finite N. Otherwise the state equation is stateuncontrollable.
1. The state equation (1) or the pair (A, B) is state controllable if and only if
the n × np state controllability matrix has rank n, i.e., full rowrank.
The state controllability matrix is given as follows:
𝑈𝑐 = [𝐵 𝐴𝐵 𝐴2𝐵 … … … 𝐴𝑛−1 𝐵]
The full rank condition can also be stated as follows: If the determinant of
the the controllability matrix is zero, then the matrixis full rank.
Observability:
The state model (or the pair (A, C) ) is said to be observable if any initial state x(0)can be
uniquely determined from the knowledge of output y(k) and input sequence u(k), for k =
0, 1, 2, · · · , N, where N is some finite time. Otherwise, the state model is unobservable.
24
Theorem of Duality:
The pair (A, B) is controllable if and only if the pair ( 𝑇,𝐵𝑇 ) is observable.
QUESTIONS:
Q1. Test the controllability and observability of the given system in both continuousand
discrete domain.
Given characteristic equation: 5𝑧2 − 2𝑧 + 2 = 0
PROCEDURE:
Finding the transfer function:
We know that any transfer function is of the form:
Thus,
The transfer function in z-domain is:
MATLAB CODE:
Q1.
H=tf([5,-2,1],[5,-2,2],0.1)
[b1 a1] = tfdata(H, 'v');
[A1,B1,C1,D1]=tf2ss(a1,b1);
g1=rank(ctrb(A1,B1));
g2=rank(obsv(A1,C1));
n = size(A1, 1);
if (g1==n || g2==n)
disp('Given system is both fully controllable and observable')elseif
(g1==n)
disp('Given system is fully controllable only')
elseif (g2==n)
disp('Given system is fully observable only')
else
disp('Given system is neither fully controllable nor observable')end
fprintf('\n')
disp('To check controllability and obsevability in s-domain')
s domain[a b] = tfdata(H, 'v');
[A,B,C,D]=tf2ss(b,a);
f1=rank(ctrb(A,B));
f2=rank(obs
v(A,C));n =
size(A, 1);
if (f1==n || f2==n)
disp('Given system is both fully controllable and
observable')elseif (f1==n)
disp('Given system is fully controllable
only')elseif (f2==n)
disp('Given system is fully observable
only')else
disp('Given system is neither fully controllable nor
observable')end
RESULT:
Thus, the given system was tested for controllability and observability in both S and Z domain.