3432
|
1 ## Copyright (C) 1997 Kai P. Mueller |
|
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 |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301 USA. |
3432
|
19 |
|
20 ## -*- texinfo -*- |
3501
|
21 ## @deftypefn {Function File} {} ctrb (@var{sys}, @var{b}) |
3502
|
22 ## @deftypefnx {Function File} {} ctrb (@var{a}, @var{b}) |
5016
|
23 ## Build controllability matrix: |
|
24 ## @iftex |
|
25 ## @tex |
|
26 ## $$ Q_s = [ B AB A^2B \ldots A^{n-1}B ] $$ |
|
27 ## @end tex |
|
28 ## @end iftex |
|
29 ## @ifinfo |
3432
|
30 ## @example |
|
31 ## 2 n-1 |
|
32 ## Qs = [ B AB A B ... A B ] |
|
33 ## @end example |
5016
|
34 ## @end ifinfo |
3432
|
35 ## |
3502
|
36 ## of a system data structure or the pair (@var{a}, @var{b}). |
3432
|
37 ## |
5016
|
38 ## @command{ctrb} forms the controllability matrix. |
|
39 ## The numerical properties of @command{is_controllable} |
3432
|
40 ## are much better for controllability tests. |
|
41 ## @end deftypefn |
|
42 |
|
43 ## Author: Kai P. Mueller <mueller@ifr.ing.tu-bs.de> |
|
44 ## Created: November 4, 1997 |
|
45 ## based on is_controllable.m of Scottedward Hodel |
|
46 |
|
47 function Qs = ctrb (sys, b) |
|
48 |
|
49 if (nargin == 2) |
|
50 a = sys; |
4030
|
51 elseif (nargin == 1 && isstruct(sys)) |
3432
|
52 sysupdate(sys,"ss"); |
|
53 [a,b] = sys2ss(sys); |
|
54 else |
6046
|
55 print_usage (); |
3432
|
56 endif |
|
57 |
|
58 if (!is_abcd(a,b)) |
|
59 Qs = []; |
|
60 else |
|
61 ## no need to check dimensions, we trust is_abcd(). |
|
62 [na, ma] = size(a); |
|
63 ## using imb avoids name conflict with the "mb" function |
|
64 [inb, imb] = size(b); |
|
65 Qs = zeros(na, ma*imb); |
|
66 for i = 1:na |
|
67 Qs(:, (i-1)*imb+1:i*imb) = b; |
|
68 b = a * b; |
|
69 endfor |
|
70 endif |
|
71 endfunction |