Mercurial > hg > octave-lojdl
comparison scripts/control/is_controllable.m @ 3228:dbcc24961c44
[project @ 1998-12-09 18:42:12 by jwe]
author | jwe |
---|---|
date | Wed, 09 Dec 1998 18:42:13 +0000 |
parents | ba1c7cdc6090 |
children | 28aba52a2368 |
comparison
equal
deleted
inserted
replaced
3227:e090571062ee | 3228:dbcc24961c44 |
---|---|
35 # is_observable, is_stabilizable, is_detectable, krylov, krylovb | 35 # is_observable, is_stabilizable, is_detectable, krylov, krylovb |
36 | 36 |
37 # Written by A. S. Hodel (scotte@eng.auburn.edu) August, 1993. | 37 # Written by A. S. Hodel (scotte@eng.auburn.edu) August, 1993. |
38 # Updated by A. S. Hodel (scotte@eng.auburn.edu) Aubust, 1995 to use krylovb | 38 # Updated by A. S. Hodel (scotte@eng.auburn.edu) Aubust, 1995 to use krylovb |
39 # Updated by John Ingram (ingraje@eng.auburn.edu) July, 1996 for packed systems | 39 # Updated by John Ingram (ingraje@eng.auburn.edu) July, 1996 for packed systems |
40 # SYS_INTERNAL accesses members of packed system structure | 40 # $Revision: 1.15 $ |
41 # $Revision: 1.14 $ | |
42 | 41 |
43 deftol = 1; # assume default tolerance | 42 deftol = 1; # assume default tolerance |
44 if(nargin < 1 | nargin > 3) | 43 if(nargin < 1 | nargin > 3) |
45 usage(sprintf("[retval,U] = %s\n\t%s", "is_controllable(a {, b ,tol})", ... | 44 usage("[retval,U] = %s\n\t%s", "is_controllable(a {, b ,tol})", ... |
46 "is_controllable(sys{,tol})")); | 45 "is_controllable(sys{,tol})"); |
47 elseif(is_struct(a)) | 46 elseif(is_struct(a)) |
48 # system structure passed. | 47 # system structure passed. |
49 sys = sysupdate(a,"ss"); | 48 sys = sysupdate(a,"ss"); |
50 [a,bs] = sys2ss(sys); | 49 [a,bs] = sys2ss(sys); |
51 if(nargin > 2) | 50 if(nargin > 2) |
66 | 65 |
67 # check for default tolerance | 66 # check for default tolerance |
68 if(deftol) tol = 1000*eps; endif | 67 if(deftol) tol = 1000*eps; endif |
69 | 68 |
70 # check tol dimensions | 69 # check tol dimensions |
71 if( !is_sample(tol) ) | 70 if( !is_scalar(tol) ) |
72 error("is_controllable: tol must be a positive scalar!"); | 71 error("is_controllable: tol(%dx%d) must be a scalar", ... |
72 rows(tol),columns(tol)); | |
73 elseif( !is_sample(tol) ) | |
74 error("is_controllable: tol=%e must be positive",tol); | |
73 endif | 75 endif |
74 | 76 |
75 # check dimensions compatibility | 77 # check dimensions compatibility |
76 n = is_square (a); | 78 n = is_square (a); |
77 [nr, nc] = size (b); | 79 [nr, nc] = size (b); |
78 | 80 |
79 if (n == 0 | n != nr | nc == 0) | 81 if (n == 0 | n != nr | nc == 0) |
80 warning(["is_controllable: a=(",num2str(rows(a)),"x", ... | 82 warning("is_controllable: a=(%dx%d), b(%dx%d)",rows(a),columns(a),nr,nc); |
81 num2str(columns(a)),"), b=(",num2str(nr),"x",num2str(nc),")"]) | |
82 retval = 0; | 83 retval = 0; |
83 else | 84 else |
84 # call block-krylov subspace routine to get an orthogonal basis | 85 # call block-krylov subspace routine to get an orthogonal basis |
85 # of the controllable subspace. | 86 # of the controllable subspace. |
86 if(nc == 1) | 87 if(nc == 1) |
87 [U,H,Ucols] = krylov(a,b,n,tol); | 88 [U,H,Ucols] = krylov(a,b,n,tol,1); |
88 U = U(:,1:Ucols); | 89 U = U(:,1:Ucols); |
89 else | 90 else |
90 [U,Ucols] = krylovb(a,b,n,tol); | 91 [U,Ucols] = krylovb(a,b,n,tol); |
91 U = U(:,1:Ucols); | 92 U = U(:,1:Ucols); |
92 endif | 93 endif |