0% found this document useful (0 votes)
12 views7 pages

Control System Lab

The document outlines various control system analysis techniques, including transfer function representation, pole-zero mapping, block diagram reduction, and stability analysis using the Routh-Hurwitz criterion. It also covers plotting singularity functions, time responses of second-order systems, polar plots, Bode plots, and the use of Simulink for block diagram representation. Each section includes MATLAB code snippets for practical implementation of these concepts.

Uploaded by

A.かす
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views7 pages

Control System Lab

The document outlines various control system analysis techniques, including transfer function representation, pole-zero mapping, block diagram reduction, and stability analysis using the Routh-Hurwitz criterion. It also covers plotting singularity functions, time responses of second-order systems, polar plots, Bode plots, and the use of Simulink for block diagram representation. Each section includes MATLAB code snippets for practical implementation of these concepts.

Uploaded by

A.かす
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Date: 15-07-2024

1. Transfer Function representation of a system


%Transfer function representation of a system
n = [1 -2 -8 0]; %numarator
d = [1 2 2 -39 -70]; %denominator
transfer_function = tf(n,d); %using the function "tf()"

2. Pole-Zero mapping of a Transfer Function


%Pole-Zero mapping of a Trans. function
G = zpk(transfer_function); %using the function "zpk()"
[Z, P, K] = tf2zp(n,d);
pzmap(n,d)

3. Block Diagram reduction technique


%Block Diagram reduction technique of a composite system

%For G1
n1 = [1 0]; %numerator 1
d1 = [1 3]; %denominator 1
G1 = tf(n1, d1);

%For G2
n2 = [1];
d2 = [1 0 0];
G2 = tf(n2, d2);

G3 = series(G1, G2); %using the function "series()"


%G4 = parallel(0); %there is no parallel combination

%Feedback
n3 = [1 1 0];
d3 = [1 12 35];
H = tf(n3, d3);

G = feedback(G3, H)

Date: 26-09-2024
4. Plotting the singularity functions (unit Impulse, Step, Ramp) with Error
%Plotting the singularity functions (Unit Impulse, Step, Ramp) with
Error
T = 1;
t = 0 : 0.01 : 10;

%For Impulse Function----


r_impulse = t == 0;
c_impulse = (1/T)*exp(-t/T);
e_impulse = (r_impulse - c_impulse);

%Plotting----------------
figure(1) %Figure 01
subplot(2,1,1)
plot(t,c_impulse);
title('Impulse Response');
xlabel('Time');
ylabel('Output');

subplot(2,1,2)
plot(t,e_impulse);
xlabel('Time');
ylabel('Error');

%For Step Function-------


r_step = 1;
c_step = 1-exp(-t/T);
e_step = (r_step - c_step);

%Plotting----------------
figure(2) %Figure 02
subplot(2,1,1)
plot(t,c_step);
title('Step Response');
xlabel('Time');
ylabel('Output');

subplot(2,1,2)
plot(t,e_step);
xlabel('Time');
ylabel('Error');

%For Ramp Function-------


r_ramp = t;
c_ramp = t-T+T.*exp(-t/T);
e_ramp = (r_ramp - c_ramp);

%Plotting----------------
figure(3) %Figure 03
subplot(2,1,1)
plot(t, r_ramp, 'g', t,c_ramp);
title('Ramp Response');
xlabel('Time');
ylabel('Output');

subplot(2,1,2)
plot(t,e_ramp);
xlabel('Time');
ylabel('Error');

Date: 30-09-2024
5. Time Response of 2nd order system
% Time response of 2nd order system
wn = 4;
zeta = 0.3; % zeta < 1
num = [wn^2];
den = [1 2*zeta*wn 0];
g = tf(num, den); % tf = Transfer Function
t = feedback (g, 1);
step(t, 10);
grid on;
hold on;

wn = 4;
zeta = 1; % zeta = 1
num = [wn^2];
den = [1 2*zeta*wn 0];
g = tf(num, den); % tf = Transfer Function
t = feedback (g, 1);
step(t, 10);
grid on;
hold on;

wn = 4;
zeta = 5; % zeta > 1
num = [wn^2];
den = [1 2*zeta*wn 0];
g = tf(num, den); % tf = Transfer Function
t = feedback (g, 1);
step(t, 10);
grid on;
legend("zeta < 1", "zeta = 1", "zeta > 1");
Date: 21-10-2024
6. Sketching Polar plot of a TF
%Polar plot of a Transfer Function

%G(s)=10/s(s+1)
w = 0:0.01:100;
figure
M = 10./(w.*sqrt(1+w.*w)); %Magnitude
P = -pi/2 - atan(w); %Phase Angle
polarplot(P,M);
rlim([0 15]);

%G(s)=10/s(s+1)(s+2)
w = 0:0.01:100;
figure
M = 10./(w.*sqrt(1+w.*w).*sqrt(4+w.*w)); %Magnitude
P = -pi/2 - atan(w) - atan(w/2); %Phase Angle
polarplot(P,M);
rlim([0 2]);

Date: 28-10-2024
7. Representation of Transfer Function using Bode Plot, Margin Function, and Array
clc
close all
clear all
s = tf('s');
T = 50 / (s*(1+0.25*s)*(1+0.1*s));
bode(T);
grid on;

close all
clear all
s = tf('s');
T = 1000 / (s*(1+0.1*s)*(1+0.001*s));
bode(T);
margin(T);
grid on;

s = tf('s');
T = 1000 / (s*(1+0.1*s)*(1+0.001*s));
[gm pm wgc wpc] = margin(T)
Margin(T);
grid on;
Date: 04-11-2024

8. Stability analysis of a system using Routh-Hurwitz criterion


% Function = S^5 + 5*S^4 + 3*S^3 + 8*S^2 + 5*S + 6 = 0

clc
clear all
close all
e = [1 5 3 8 5 6 1];

% Making the array as even numbered


l = length(e);
m = mod(l, 2);
if m == 1
e = [e 0];
l1 = length(e);
end

% Making the first 2-row of Rowth-Hurwitz table


for i = 1 : l1/2
a(i) = e(2*i-1);
b(i) = e(2*i);
end

l1 = length(a);
c = zeros(l, l1); % Zero matrix of l x l1
c(1, : ) = a;
c(2, : ) = b;

for m = 3 : l
for n = 1 : l1-1
c(m,n)=-(1/c(m-1, 1))*det([c(m-2, 1) c(m-2, n+1); c(m-1, 1)
c(m-1, n+1)]);
end
end
disp(c);

Special case 1: First column element of any row = 0


% Rowth-Hurwitz Criteria
% Function = S^5 + 5*S^4 + 3*S^3 + 8*S^2 + 5*S + 6 = 0
%Special Case 1: First column element of any row = 0

clc
clear all
close all
e = [1 6 3 2 1 1]; % e = [1 2 6 4 1] (for example 5.1)
% Making the array as even numbered
l = length(e);
m = mod(l, 2);
if m == 1
e = [e 0];
end
l1 = length(e);
% Making the first 2-row of Rouh-Hurwitz table
for i = 1 : l1/2
a(i) = e(2*i-1);
b(i) = e(2*i);
end

l2 = length(a);
c = zeros(l, l2); % Zero matrix of l x l1
c(1, : ) = a;
c(2, : ) = b;

for m = 3 : l
for n = 1 : l2-1
c(m,n)=-(1/c(m-1, 1))*det([c(m-2, 1) c(m-2, n+1); c(m-1, 1)
c(m-1, n+1)]);
end
end
disp(c);

Special case 2: Every element of a row = 0


% Routh-Hurwitz Criteria
% Function = S^5 + 2*S^4 + 24*S^3 + 48*S^2 - 25*S - 50 = 0
%Special Case 2: Every element of a row = 0

clc
clear all
close all
e = [1 2 24 48 -25 -50];

% Making the array as even numbered


l = length(e);
m = mod(l, 2);
if m == 1
e = [e 0];
l1 = length(e);
else l1 = l;
end

% Making the first 2-row of Routh-Hurwitz table


for i = 1 : l1/2
a(i) = e(2*i-1);
b(i) = e(2*i);
end

l2 = length(a);
c = zeros(l, l2); % Zero matrix of l x l2
c(1, :) = a;
c(2, :) = b;

for p = 3 : l % loop from 3 to L


for q = 1 : l2-1
c(p,q)=-(1/c(p-1, 1))*det([c(p-2, 1) c(p-2, q+1); c(p-1, 1)
c(p-1, q+1)]);
end
if all(c(p, :) == 0)
aux_poly = polyder(c(p-1, :));
c(p, 1:length(aux_poly)) = aux_poly;
end
end
disp(c);

Date: 17-11-2024
9. Block Diagram Representation of a unity feedback system using Simulink

You might also like