-
Notifications
You must be signed in to change notification settings - Fork 2
/
root_locus_animation.m
124 lines (97 loc) · 2.54 KB
/
root_locus_animation.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
clear all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %G(s)=K/(s+5)
% % D(s)=(s +5) +K=0 % [s/5 K+1] =0;
% hold on,
% for K=0:.05:10
% y=roots([1/5 1+K]);
% y1=y(1,:);
% plot(real(y1),imag(y1),'*','color',[0,0,1]);
% pause(0.05)
% end
%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%
%
% G(s)=K(s + 1)/(s + 5)
% hold on,
% for K=0:.1:20
% y=roots([1+K 5+K]);
% y1=y(1,:);
% plot(real(y1),imag(y1),'*','color',[0,0,1]);
% pause(0.05)
% end
%
%
% % %%%%%%%%%%%%%%%%%
% % %%%%%%%%%%%%%%%%%%%%%%%%%
%G(s)=K/(s + 5)(s +2)
% hold on,
% for K=0:.01:5
% y=roots([(1/10) (1/5 + 1/2) 1+K]);
% y1=y(1,:);
% y2=y(2,:);
% plot(real(y1),imag(y1),'*','color',[0,0,1]);
% plot(real(y2),imag(y2),'*','color',[1,0,0])
% pause(0.1)
% end
%
%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%
% s^2/10 + s2/10 + (1+K)=0
hold on,
for K=0:.1:5
y=roots([(1/10) 2/10 1+K]);
y1=y(1,:);
y2=y(2,:);
plot(real(y1),imag(y1),'*','color',[0,0,1]);
plot(real(y2),imag(y2),'*','color',[1,0,0])
pause(0.1)
end
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % G(s)=K/s(s^2+ 3s + 2)
% hold on,
% for K=0:.01:10
% y=roots([1 3 2 K]);
% y1=y(1,:);
% y2=y(2,:);
% y3=y(3,:);
% plot(real(y1),imag(y1),'*','color',[0,0,1]);
% plot(real(y2),imag(y2),'*','color',[1,0,0])
% plot(real(y3),imag(y3),'*','color',[0,1,1])
% pause(0.05)
% end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % G(s)=K/s(s+3)(s^2 +2s +2)
% hold on,
% % axis(-100, 100, -100, 100);
% %y=zeros(2,100);
% for K=0:.2:20
% y=roots([1 5 8 6 K]);
% y1=y(1,:);
% y2=y(2,:);
% y3=y(3,:);
% y4=y(4,:);
% plot(real(y1),imag(y1),'*');
% plot(real(y2),imag(y2),'*')
% plot(real(y3),imag(y3),'*')
% plot(real(y4),imag(y4),'*')
% pause(0.5)
% end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% hold on,
% % G(s)=K(s+2)/(s^2 +2s +2)
% %K varies from zero to infinity
% for K=0:.05:20
% % calculate roots of the syste,
% y=roots([1 2+K 2*K+2]);
% %since this is a second order system there will be two roots and the
% %roots are stored in column of the matrix.
% y1=y(1,:);
% y2=y(2,:);
% %plot the real vs imaginory component of each root.
% plot(real(y1),imag(y1),'*','color',[0,0,1]);
% plot(real(y2),imag(y2),'*','color',[1,0,0])
% pause(0.5)
% end