Professional Documents
Culture Documents
4 Plot the Bode Plots of Lead Compensator and Lag Compensator using 07/08/2023 21
MATLAB
5 Plot the Polar Plots of Lead Compensator and Lag Compensator using 14/08/2023 24
MATLAB.
6 Design and analysis of a PID Controller using Direct Synthesis Method 28/08/2023 26
for given system. Write a MATLAB program for unite step response of
closed loop control system.
8 State Transition Matrix (STM) for given system. Also find the solution of 11/09/2023 33
state equation for initial condition. Verify your answers using MATLAB
program.
9 Develop a MATLAB program for pole placement for given dynamical 18/09/2023
system.
1
EXPERIMENT 1
AIM: Demostrat the use of MATLAB programming tools in digital signal processing.
CODE:
A=[11 12 13 14 ; 21 22 23 24 ; 31 32 33 34 ; 41 42 43 44 ]
A=
11 12 13 14
21 22 23 24
31 32 33 34
41 42 43 44
>> A(:,1)
ans =
11
21
31
41
>> A(2,:)
ans =
21 22 23 24
>> A(:,2:3)
ans =
12 13 4
2
22 23 4
32 33 4
42 43
>> A(2:3,2:3)
ans =
22 23
32 33
>> A(:,1:2:3)
ans =
11 13
21 23
31 33
41 43
>> A(2:3)
ans =
21 31
>> A(:)
ans =
11
21
31
41
3
12
22
32
42
13
23
33
43
14
24
34
44
>> A(:,:)
ans =
11 12 13 14
21 22 23 24
31 32 33 34
41 42 43 44
>> ones(2,2)
ans =
1 1
1 1
>> eye(2)
ans =
1 0
4
0 1
>> B=[A,[ones(2,2);eye(2)]]
B=
11 12 13 14 1 1
21 22 23 24 1 1
31 32 33 34 1 0
41 42 43 44 0 1
>> diag(A)
ans =
11
22
33
44
>> diag(A,1)
ans =
12
23
34
>> diag(A,-1)
ans =
21
32
5
43
>> diag(A,2)
ans =
13
24
>> eig(A)
ans =
111.7891
-1.7891
0.0000
-0.0000
>> poly(A)
ans =
1 2 3 4
B=
1 2 3 4 5 6
6
C=
1 2 3 4 1 2 3 4
A=
1 2 3
4 5 6
7 8 9
ans =
1 4 9
16 25 36
49 64 81
ans =
30 36 42
66 81 96
102 126 150
7
M*sin(L)*M^-1
A=
0 1.0472
0.5236 1.5708
B1 =
0 0.8660
0.5000 1.0000
B2 =
1.0000 0.5000
0.8660 0.0000
ans =
1 1
1 1
ML =
-0.2940
1.8648
8
A=
0.8147 0.1270
0.9058 0.9134
B=
0.6324 0.2785
0.0975 0.5469
C=
0.9575 0.1576
0.9649 0.9706
D=
0.9572 0.8003
0.4854 0.1419
E=
0.4218 0.7922
0.9157 0.9595
F =
7.8396 6.7954
-14.8750 -12.5168
theta=0:0.012*pi;
r1=3*(1-cos( theta));
figure
polarplot(theta,r1)
figure
9
r2=2*(1+cos(theta));
polarplot(theta,r1)
r3=2*(1+sin(theta));
figure
polarplot(theta,r3)
r4=cos(3*theta); figure
polarplot(theta,r4)
r5=exp((theta/4)*pi);
figure
polarplot(theta,r5)
Conclusion - From the above practical we can learn about the use of matlab
programming tools in digital signal processing .
10
EXPERIMANT 2
THEORY:
A lead compensator in root locus form is given by where the magnitude of zeros is less
than the magnitude of poles. toward the left half plane. A lead compensator improves
stability and response speed. It has a zero and a pole, with the zero’s magnitude smaller
than the pole’s. This shifts the asymptotes’ intersection to the left, moving the entire
root locus leftward. It increases stability and response speed. The net number of zeros
and poles remains the same, with one zero and one pole added. The added pole has a
larger negative value than the added zero.
CODE:
>> num=[1]
num =
1
>> den=[0.5 1.5 1]
den =
0.5000 1.5000 1.0000
>> sys=tf(num,den)
Transfer function:
1
11
------------------- 0.5
s^2 + 1.5 s + 1
>> sys_c=tf([5 0.5],[1 0.001])
Transfer function:
5 s + 0.5
---------
s+0.001
>>out=step(sys)
out = 0
0.0026
0.0097
0.0208
0.0352
0.0523
>> plot(out)
>> step(sys)
>> step(sys_c)
>> y1=stepinfo(sys)
RESULT:
y1 =
RiseTime: 2.5901
SettlingTime: 4.6005
SettlingMin: 0.9041
SettlingMax: 0.9995
Overshoot: 0
Undershoot: 0
Peak: 0.9995
PeakTime: 8.2591
>> y2=stepinfo(sys_c)
y2 = RiseTime: 2.1973e+003
SettlingTime: 3.9124e+003
12
SettlingMin: 450.7761
SettlingMax: 499.8005
Overshoot:
Undershoot: 0
Peak: 499.8005
PeakTime: 7.8163e+003
>> rlocus(sys)
>> rlocus(sys_c)
>> sisotool(sys)
13
Conclusion : In this practical we can understand successfully the use of a lead compensator
in control system design can lead to enhanced system performance , faster response times,
and improved stability.
14
EXPERIMANT 3
THEORY:
A phase-lag compensator tends to shift the root locus to the right, which is undesirable.
For this reason, the pole and zero of a lag compensator must be placed close together
(usually near the origin) so they do not appreciably change the transient response or
stability characteristics of the system. When a lag compensator is added to a system, the
value of this intersection will be a smaller negative number than it was before. The net
number of zeros and poles will be the same (one zero and one pole are added), but the
added pole is a smaller negative number than the added zero. Thus, the result of a lag
compensator is that the asymptotes' intersection is moved closer to the right half plane,
and the entire root locus will be shifted to the right.
CODE:
>> %Unit-step Response%
num=[0 0 4];
den=[1 3 4];
numc=[0 0 166.8 735.588];
denc=[1 20.4 203.6 735.588]; t=0:0.02:6;
[c1,x2,t]=step(num,den,t); [c2,x2,t]=step(numc,denc,t); figure; plot(t,c1'.',t,c2,'-')
grid title('unit-step responsees of compensated and uncompensated system')
xlabel('tsec') ylabel('outputs')
15
text(0.4,1.31,'compensated system')
text(1.55,0.88,'uncompensated system')
h=tf(num,den) hc=tf(numc,denc)
[wn,zeta]=damp(h) tau=1/(zeta.*wn)
[wnc,zetac]=damp(hc)
tauc=1./(zetac.*wnc)
S1=stepinfo(h,'RiseTimeLimits',[0.1,0.9])
S1=stepinfo(hc,'RiseTimeLimits',[0.1,0.9])
%unit-ramp response% num1=[0 0 0 4];
den1=[1 2 4 0]; numc1=[0 0 0 166.8
735.588]; denc1=[1 20.4 203.6
735.588]; t=0:0.02:5;
[y1,z1,t]=step(num1,den1,t);
[y2,z2,t]=step(numc1,denc1,t); figure;
plot(t,y1,'.',t,y2,'-',t,t,'--')
grid title('unit-Ramp responsees of compensated and uncompensated
system') xlabel('tsec') ylabel('outputs') text(0.89,3.7,'compensated system')
text(2.25,1.1,'uncompensated system') h=tf(num,den) hc=tf(numc,denc)
[wn,zeta]=damp(h) tau=1./(zeta.*wn) [wnc,zetac]=damp(hc)
tauc=1./(zetac.*wnc)
S1=stepinfo(h,'RiseTimeLimits',[0.1 0.9])
S2=stepinfo(hc,'RiseTimeLimits',[0.1 0.9])
RESULT:
Transfer function: 4 /s^2 + 3 s + 4
Transfer function: 166.8 s + 735.6 /s^3 + 20.4 s^2 + 203.6 s + 735.6
wn = 2.0000 2.0000 zeta = 0.7500 0.7500 tau = 0.6667 0 wnc =
6.4918 10.6448 10.6448 zetac = 1.0000 0.6533 0.6533 tauc =
0.1540 0.1438 0.1438
S1 = RiseTime: 1.1441
SettlingTime: 2.8713
SettlingMin: 0.9002
SettlingMax: 1.0284
Overshoot: 2.8375
16
Undershoot: 0
Peak: 1.0284
PeakTime: 2.3781
S1 = RiseTime: 0.1342
SettlingTime: 0.6186
SettlingMin: 0.9044
SettlingMax: 1.2168
Overshoot: 21.6834
Undershoot: 0
Peak: 1.2168
PeakTime: 0.3244
Transfer function: 4 ------------- s^2 + 3 s + 4
Transfer function: 166.8 s + 735.6 -------------------------------- s^3 + 20.4 s^2 + 203.6
s + 735.6 wn = 2.0000 2.0000 zeta = 0.7500 0.7500 tau = 0.6667 0.6667 wnc =
6.4918 10.6448 10.6448 zetac = 1.0000 0.6533 tauc = 0.1540 0.1438 0.1438 S1 =
RiseTime: 1.1441
SettlingTime: 2.8713
SettlingMin: 0.9002
SettlingMax: 1.0284
Overshoot: 2.8375
Undershoot: 0
Peak: 1.0284
PeakTime: 2.3781
S2 = RiseTime: 0.1342
SettlingTime: 0.6186
SettlingMin: 0.9044
SettlingMax: 1.2168
Overshoot: 21.6834
Undershoot: 0
Peak: 1.2168
17
PeakTime: 0. 3244 >>
18
EXPERIMENT 4
AIM: Plot the Bode Plots of Lead Compensator and Lag Compensator using
MATLAB.
Assume kc=1, T=1, α=0.1 for Lead Compensator and β=10 for Lag Compensator.
THEORY:
A Bode plot of a phase lead compensator has the following form .The two corner
frequencies are at 1/αt and 1/t; note the positive phase that is added to the system
between these two frequencies. Lead angle : Φm= γd+€-γ α=1-sinϕm/1+sinϕm
t=1/Wm√t
Gc(s)=s+(1/t)/s+(1/αt)
A bode plot of a phase lag compensator has the following form.The two corner
frequencies are at 1/βt and 1/t .The main effect of the lag compensator is shown in the
magnitude plot .The lag compensator adds gain at low frequencies the magnitude of the
gain is equal to β.
β=10Agcn/20 t=10/Wgcn
Gc(s)=s+(1/t)/s+(1/βt)
CODE:
>> % Aim: Plot the bode plot of Lead Compensator using Matlab.
% Assume kc=1, T=1, alpha=0.1 for lead
compensator using Matlab
w=logspace(-1,3,200); k=1;
[mag,phase,w]=bode([1 1],[1 0.1],w);
mag1db=20*log10(mag);
phase1=phase; semilogx(w,mag1db,'-');
19
'); grid xlabel('frequency(rad/sec)')
ylabel('phase(deg)') %text(0.2,-
90,'k=1') >>
OUTPUT:
20
Conclusion :- we can learn successfully about plot the bode plot of
lead compansator and lag compansator by using the Matlab
21
EXPERIMENT 5
AIM: Plot the Polar Plots of Lead Compensator and Lag Compensator using
MATLAB.
Assume kc=1, T=1, α=0.1 for Lead Compensator and β=10 for Lag Compensator.
THEORY:-
It is a plot of the magnitude of G(jω) versus the phase angle of G(jω) on polar
coordinates as ω is varied from zero to infinity In polar plots a positive (negative) phase
angle is measured counterclockwise (clockwise) from the positive real axis
CODE:
lead=tf([1 1],[1 0.1])
Nyquist(lead)
lead =
s+1
------- s
+ 0.1
22
OutputName: {''}
OutputUnit: {''}
OutputGroup: [1×1 struct]
Notes: [0×1 string]
UserData: []
Name: ''
Ts: 0
TimeUnit: 'seconds'
SamplingGrid: [1×1 struct]
Conclusion : In this practical we successfully learn Plot the Polar Plots of Lead
Compensator and Lag Compensator by using matlab.
23
EXPERIMENT 6
AIM: Design and analysis of a PID Controller using Direct Synthesis Method for
given system. Write a MATLAB program for unite step response of closed loop
control system.
THEORY :-
nump=[0 0 1]
denp=[12 7 1]
gp=tf(nump,denp)
numc=[12 7 1]
denc=[0 10 0]
gc=tf(numc,denc)
g=feedback(gp*gc,1)
step(g) v=[0 90 0
1.6] axis (v)
grid hold
on pd
=c2d(gp,
24
1,'tustin')
cd=c2d
(gc,1,'tust
in')
gd=feedb
ack(pd*c
d,1)
step(gd,'--')
nump = 0 0 1
denp = 12 7 1 gp
=
1
----------------
12 s^2 + 7 s + 1
25
---------------------------------
z^2 - 1.492 z + 0.5556 Sample
time: 1 seconds
26
Name: ''
Ts: 0
TimeUnit: 'seconds'
SamplingGrid: [1×1 struct]
Conclusion:- In this practical we can learn successfully about the Design and analysis
of PID controller using direct synthesis method.
27
EXPERIMENT 7
THEORY:-
State-space model is commonly used for representing a linear time-invariant (LTI) ystem. It
describes a system with a set of first-order differential or difference equations using inputs,
outputs, and state variables. In the absence of these equations, a model of a desired order (or
number of states) can be estimated from measured input-output data.
The models are widely used A in modern control applications for designing controllers and
analyzing system performance in the time domain and frequency domain. The models can be
applied to nonlinear systems or systems with non-zero initial conditions. They also provide a
convenient way to represent, analyze, and control multi-input/multi-output (MIMO) systems.
CODE:
a=[0 1 0; 0 0 1; -5.008 -25.1026 -5.03247];
b=[0;25.04;-121.005]; c=[1 0 0]; d=[0];
[num,den]=ss2tf(a,b,c,d) num=[0 -
0.0000 25.0400 5.0080] den=[1.0000
5.0325 25.1026 5.0080]
[num,den]=ss2tf(a,b,c,d,1) num=[0
-0.0000 25.0400 5.0080]
den=[1.0000 5.0325 25.1026 5.0080]
RESULT:
num =
0 0 25.0400 5.0080
28
den =
num =
0 0 25.0400 5.0080
den =
num =
0 0 25.0400 5.0080
den =
num =
0 0 25.0400 5.0080
den =
29
Conclusion : In this practical we are learned ,To obtain State-Space Representation
of given T.F. and vice-versa using MATLAB
30
EXPERIMENT 8
AIM: State Transition Matrix (STM) for given system. Also find the solution of state
equation for initial condition. Verify your answers using MATLAB program.
THEORY:-
State space analysis of control system is based on the modern theory which is applicable
to all types of systems like single input single output systems, multiple inputs and
multiple outputs systems, linear and non linear systems, time varying and time invariant
systems. Let us consider few basic terms related to state space analysis of modern theory
of control systems.
1. State in State Space Analysis : It refers to smallest set of variables whose
knowledge at t = t0 together with the knowledge of input for t ≥ t0 gives the
complete knowledge of the behavior of the system at any time t ≥ t0.
2. State Variables in State Space analysis : It refers to the smallest set of
variables which help us to determine the state of the dynamic system. State
variables are defined by x1(t), x2(t)……..Xn(t).
3. State Vector : Suppose there is a requirement of n state variables in order to
describe the complete behavior of the given system, then these n state variables
are considered to be n components of a vector x(t). Such a vector is known as
state vector.
4. State Space : It refers to the n dimensional space which has x1 axis, x2 axis
………xn axis.
Y=Cx+Du(t)
X=state vector
A=state matrix
B=input matrix
31
C=output matrix
Y= output
CODE:
A=[-2 1 0;0 -3 1;-3 -4 -5]
B=[0;0;1]
C=[0 1 0]
D=[0] Y=impulse(A,B,C,D)
plot(Y)
xlabel('t') ylabel('output')
title('impulse response')
A=
-2 1 0
0 -3 1
-3 -4 -5
B=
0
0
1
C=
[0 1 0]
D=
[0]
Y=
0.0165 0.0165 0.0165 0.0165 0.0165 0.0165 0.0165 0.0165 0.0165 0.0165
0.0307 0.0307 0.0307 0.0307 0.0307 0.0307 0.0307 0.0307 0.0307 0.0307
32
0.0428 0.0428 0.0428 0.0428 0.0428 0.0428 0.0428 0.0428 0.0428 0.0428
0.0531 0.0531 0.0531 0.0531 0.0531 0.0531 0.0531 0.0531 0.0531 0.0531
0.0618 0.0618 0.0618 0.0618 0.0618 0.0618 0.0618 0.0618 0.0618 0.0618
0.0690 0.0690 0.0690 0.0690 0.0690 0.0690 0.0690 0.0690 0.0690 0.0690
0.0748 0.0748 0.0748 0.0748 0.0748 0.0748 0.0748 0.0748 0.0748 0.0748
0.0795 0.0795 0.0795 0.0795 0.0795 0.0795 0.0795 0.0795 0.0795 0.0795
Conclusion: In this practical we learn the Transition Matrix Also find the solution of state
equation for initial condition.
EXPERIMENT 9
AIM: Develop a MATLAB program for pole placement for given dynamical system.
•
33
Consider the system given by : X =AX+Bu, y=CX
Where, 0 1 0 , B= 0 .
A= 00 1 1
−1 −5 −6
The system uses the state feedback control
u=−Kx(k). It is desired to have closed-loop
poles at
s =−2− j4, s =−2+ j4, and s =−10. Determine the
state feedback gain matrix K .
THEORY:-
Pole placement is a method of calculating the optimum gain matrix used to assign
closed-loop poles to specified locations, thereby ensuring system stability. Closed-loop
pole locations have a direct impact on time response characteristics such as rise time,
settling time, and transient oscillations.
CODE:
OIUTPUT
A=
1 1 0
0 0 1
2 -5 -6
B=
0
0
34
1
J = -2.0000 + 4.0000i -2.0000 - 4.0000i -10.0000 + 0.0000i
K = 199.0000 55.0000 8.0000 K = 199 55 8
Conclusion:- In this above practical we learn about state transition Matrix and also
obtained the solution of state equation for initial condition by using matlab
programming.
35