comparison scripts/control/base/rlocus.m @ 6413:cf8e671beada

[project @ 2007-03-15 14:11:51 by jwe]
author jwe
date Thu, 15 Mar 2007 14:11:51 +0000
parents a8dd70bacc1e
children 6b1535a09268
comparison
equal deleted inserted replaced
6412:b2096bb759b1 6413:cf8e671beada
225 n_rlpol = rows(rlpol); 225 n_rlpol = rows(rlpol);
226 nelts = n_rlpol+1; 226 nelts = n_rlpol+1;
227 if (! isempty (rlzer)) 227 if (! isempty (rlzer))
228 nelts++; 228 nelts++;
229 endif 229 endif
230 # add asymptotes
231 n_A = length (olpol) - length (olzer);
232 if (n_A > 0)
233 nelts += n_A;
234 endif
230 args = cell (3, nelts); 235 args = cell (3, nelts);
231 for kk=1:rows(rlpol) 236 kk = 0;
232 args{1,kk} = real (rlpol (kk,:)); 237 # asymptotes first
233 args{2,kk} = imag (rlpol (kk,:)); 238 if (n_A > 0)
234 args{3,kk} = "b-"; 239 len_A = 2*max(abs(axlim));
235 endfor 240 sigma_A = (sum(olpol) - sum(olzer))/n_A;
236 args{1,n_rlpol+1} = real(olpol); 241 for i_A=0:n_A-1
237 args{2,n_rlpol+1} = imag(olpol); 242 phi_A = pi*(2*i_A + 1)/n_A;
238 args{3,n_rlpol+1} = "rx;open loop poles;"; 243 args{1,++kk} = [sigma_A sigma_A+len_A*cos(phi_A)];
239 244 args{2,kk} = [0 len_A*sin(phi_A)];
245 if (i_A == 1)
246 args{3,kk} = "k-;asymptotes;";
247 else
248 args{3,kk} = "k-";
249 endif
250 endfor
251 endif
252 # locus next
253 for ii=1:rows(rlpol)
254 args{1,++kk} = real (rlpol (ii,:));
255 args{2,kk} = imag (rlpol (ii,:));
256 if (ii == 1)
257 args{3,kk} = "b-;locus;";
258 else
259 args{3,kk} = "b-";
260 endif
261 endfor
262 # poles and zeros last
263 args{1,++kk} = real(olpol);
264 args{2,kk} = imag(olpol);
265 args{3,kk} = "rx;open loop poles;";
240 if (! isempty(rlzer)) 266 if (! isempty(rlzer))
241 args{1,n_rlpol+2} = real(rlzer); 267 args{1,++kk} = real(rlzer);
242 args{2,n_rlpol+2} = imag(rlzer); 268 args{2,kk} = imag(rlzer);
243 args{3,n_rlpol+2} = "go;zeros;"; 269 args{3,kk} = "go;zeros;";
244 endif 270 endif
245 271
246 plot (args{:}) 272 set (gcf,"visible","off");
273 hplt = plot (args{:});
274 set (hplt(kk--), "markersize", 2);
275 if (! isempty(rlzer))
276 set(hplt(kk--), "markersize", 2);
277 endif
278 for ii=1:rows(rlpol)
279 set (hplt(kk--), "linewidth", 2);
280 endfor
247 legend ("boxon", 2); 281 legend ("boxon", 2);
248 grid ("on"); 282 grid ("on");
249 axis (axlim); 283 axis (axlim);
250 xlabel (sprintf ("Root locus from %s to %s, gain=[%f,%f]: Real axis", 284 xlabel (sprintf ("Root locus from %s to %s, gain=[%f,%f]: Real axis",
251 inname{1}, outname{1}, gvec(1), gvec(ngain))); 285 inname{1}, outname{1}, gvec(1), gvec(ngain)));
252 ylabel ("Imag. axis"); 286 ylabel ("Imag. axis");
287 set (gcf,"visible","on");
253 rldata = []; 288 rldata = [];
254 endif 289 endif
255 endfunction 290 endfunction
256 291
257 function rlpol = sort_roots (rlpol,tolx, toly) 292 function rlpol = sort_roots (rlpol,tolx, toly)