-
Notifications
You must be signed in to change notification settings - Fork 0
/
task4_check.m
73 lines (60 loc) · 1.27 KB
/
task4_check.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function [] = task4_check(ss,t,u0,u1,u2,u3,x0)
%TASK4_CHECK Summary of this function goes here
% Detailed explanation goes here
% check if external stable (x0)
% u1=[1 0]
[y, t, x] = lsim(ss, u1, t, x0);
figure;
for i = 1:2
plot(t,y(:,i));
legend_str{i} = ['y',num2str(i)];
hold on;
end
legend(legend_str);
xlabel('Time (sec)');
ylabel('y');
sgtitle('Output response with input u=[1 0]');
% u2=[0 1]
[y, t, x] = lsim(ss, u2, t, x0);
figure;
for i = 1:2
plot(t,y(:,i));
legend_str{i} = ['y',num2str(i)];
hold on;
end
legend(legend_str);
xlabel('Time (sec)');
ylabel('y');
sgtitle('Output response with input u=[0 1]');
% u3=[1 1]
[y, t, x] = lsim(ss, u3, t, x0);
figure;
for i = 1:2
plot(t,y(:,i));
legend_str{i} = ['y',num2str(i)];
hold on;
end
legend(legend_str);
xlabel('Time (sec)');
ylabel('y');
sgtitle('Output response with input u=[1 1]');
% u3=[0 0]
[y, t, x] = lsim(ss, u0, t, x0);
figure;
for i = 1:2
plot(t,y(:,i));
legend_str{i} = ['y',num2str(i)];
hold on;
end
legend(legend_str);
xlabel('Time (sec)');
ylabel('y');
sgtitle('Output response with input u=[0 0]');
% check if internally stable
p=pole(ss);
for i=1:size(p)
if real(p(i))>0
disp(['Find pole with negative part:',num2str(p(i))]);
end
end
end