3381
|
1 ## Copyright (C) 1996,1998 Auburn University. All Rights Reserved. |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by the |
|
7 ## Free Software Foundation; either version 2, or (at your option) any |
|
8 ## later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 ## for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. |
3213
|
18 |
3346
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File } { [@var{n}, @var{nz}, @var{m}, @var{p},@var{yd}] =} sysdimensions (@var{sys}@{, @var{opt}@}) |
|
21 ## return the number of states, inputs, and/or outputs in the system @var{sys}. |
|
22 ## |
|
23 ## @strong{Inputs} |
|
24 ## @table @var |
|
25 ## @item sys |
|
26 ## system data structure |
|
27 ## |
|
28 ## @item opt |
|
29 ## String indicating which dimensions are desired. Values: |
|
30 ## @table @code |
|
31 ## @item "all" |
|
32 ## (default) return all parameters as specified under Outputs below. |
|
33 ## |
|
34 ## @item "cst" |
|
35 ## return @var{n}= number of continuous states |
|
36 ## |
|
37 ## @item "dst" |
|
38 ## return @var{n}= number of discrete states |
|
39 ## |
|
40 ## @item "in" |
|
41 ## return @var{n}= number of inputs |
|
42 ## |
|
43 ## @item "out" |
|
44 ## return @var{n}= number of outputs |
|
45 ## @end table |
|
46 ## @end table |
|
47 ## |
|
48 ## @strong{Outputs} |
|
49 ## @table @var |
|
50 ## @item n |
|
51 ## number of continuous states (or individual requested dimension as specified |
|
52 ## by @var{opt}). |
|
53 ## @item nz |
|
54 ## number of discrete states |
|
55 ## @item m |
|
56 ## number of system inputs |
|
57 ## @item p |
|
58 ## number of system outputs |
|
59 ## @item yd |
|
60 ## binary vector; @var{yd}(@var{ii}) is nonzero if output @var{ii} is |
|
61 ## discrete. |
|
62 ## @math{yd(ii) = 0} if output @var{ii} is continous |
|
63 ## @end table |
|
64 ## |
|
65 ## @end deftypefn |
|
66 |
|
67 ## See also: sysgetsignals, sysgettsam |
|
68 |
3385
|
69 function [n, nz, m, p, yd] = sysdimensions (sys, opt) |
3228
|
70 if(nargout > 5 | nargin < 1 | nargin > 2) |
|
71 usage("[n,nz,m,p[,yd]] = sysdimensions(sys{,opt})"); |
3213
|
72 elseif(!is_struct(sys)) |
|
73 usage("[n,nz,m,p] = sysdimensions(sys)"); |
3228
|
74 elseif(nargin == 1) |
|
75 opt = "all"; |
3213
|
76 endif |
|
77 |
|
78 n = sys.n; |
|
79 nz = sys.nz; |
3228
|
80 m = length(sysgetsignals(sys,"in")); |
|
81 p = length(sysgetsignals(sys,"out")); |
3213
|
82 yd = sys.yd; |
3240
|
83 legal_options = list("all","cst","dst","st","in","out"); |
|
84 legal_values = list(n,n,nz,n+nz,m,p); |
3228
|
85 |
3240
|
86 legal_opt = 0; |
3228
|
87 for ii=1:length(legal_options) |
|
88 if(strcmp(nth(legal_options,ii),opt)) |
|
89 n = nth(legal_values,ii); |
3240
|
90 legal_opt = 1; |
3228
|
91 if(ii > 1 & nargout > 1) |
|
92 warning("opt=%s, %d output arguments requested",opt,nargout); |
|
93 endif |
|
94 endif |
|
95 endfor |
3240
|
96 if(!legal_opt) |
|
97 error("illegal option passed = %s",opt); |
|
98 endif |
3213
|
99 |
|
100 endfunction |