0% found this document useful (0 votes)
32 views2 pages

All All: %% Question A %controllability Matrix

This document contains code that analyzes the controllability and observability of a linear system. It determines that the system is controllable from both the input I and disturbance input Td. It calculates the eigenvalues of the system and designs a state feedback controller using pole placement. Finally, it simulates the closed loop system response to disturbances and a step input to show that the system does not converge to zero.

Uploaded by

Bas de Jong
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)
32 views2 pages

All All: %% Question A %controllability Matrix

This document contains code that analyzes the controllability and observability of a linear system. It determines that the system is controllable from both the input I and disturbance input Td. It calculates the eigenvalues of the system and designs a state feedback controller using pole placement. Finally, it simulates the closed loop system response to disturbances and a step input to show that the system does not converge to zero.

Uploaded by

Bas de Jong
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
You are on page 1/ 2

Bas de Bruijne, student id: 4454685

Exersize set 4, question 3


close all
clear all
clc

J1 = 10/9;
J2 = 10;
c = 0.1;
k = 1;
ki = 1;
A = [[0 0 1 0];[0 0 0 1];[-k/J1 k/J1 -c/J1 c/J1];[k/J2 -k/J2 c/J2 -c/J2]];
B = [[0 0];[0 0];[ki/J1 0];[0 1/J1]];
C = [[1 0 0 0];[0 1 0 0]];
D = zeros(2);

sys = ss(A, B, C, D);

%% Question a
K = ctrb(A, B(:, 1)); %controllability matrix
if (rank(K) == 4)
disp("System is controllable from I")
else
disp("System is not controllable from I")
end

K = ctrb(A, B(:, 2)); %controllability matrix


if (rank(K) == 4)
disp("System is controllable from Td")
else
disp("System is not controllable from Td")
end

Returns that system is controllable from both I and Td, eventhough Td is a disturbance input.

%% Question b
[V, lamda] = eig(A)

Indeed returns that the eigenvalues are -5+/-i and 0 (2x)

%% Question c
F = place(A,B(:,1),[-2, -1, -1+i, -1-i]')

Output: F =
8.9333 35.5111 5.4444 101.2222

%% Question d
cl=ss(A-B(:, 1)*F,B(:, 2),C,0);
figure(1);clf;
for i = 0:.1:1-.1
x0=[i*20;0;i*20;0];
dt = 0.001;
tu = 0:dt:20;
[yn,tn]=lsim(cl,0*tu,tu,x0);
subplot(2,1,1);
hold on
plot(tn,yn(:, 1), 'color', ones(1,3)*(1-i))
subplot(2,1,2);
hold on
plot(tn,yn(:, 2), 'color', ones(1,3)*(1-i))
end
subplot(2,1,1);
title('Output 1')
subplot(2,1,2);
title('Output 2')
x0=[i;0;i;0];
dt = 0.001;
tu = 0:dt:20;
[yn,tn]=lsim(cl,ones(size(tu)),tu,x0);
subplot(2,1,1);
hold on
plot(tn,yn(:, 1), 'color', [1 0 0])
subplot(2,1,2);
hold on
plot(tn,yn(:, 2), 'color', [1 0 0])

Plot:

Black lines are different disturbances for x0, red line is step response for disturbance input

%% Question e
DCGain = dcgain(cl)

Output: DCGain =
-6.9885
2.0115

So the system does not converge to zero

You might also like