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 |
|
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. |
|
18 |
|
19 ## -*- texinfo -*- |
3500
|
20 ## @deftypefn {Function File} {} ctrb(@var{sys}, @var{b}) |
|
21 ## @deftypefnx {Function File} {} ctrb(@var{A}, @var{B}) |
3432
|
22 ## Build controllability matrix |
|
23 ## @example |
|
24 ## 2 n-1 |
|
25 ## Qs = [ B AB A B ... A B ] |
|
26 ## @end example |
|
27 ## |
|
28 ## of a system data structure or the pair (@var{A}, @var{B}). |
|
29 ## |
|
30 ## @strong{Note} @code{ctrb} forms the controllability matrix. |
|
31 ## The numerical properties of @code{is_controllable} |
|
32 ## are much better for controllability tests. |
|
33 ## @end deftypefn |
|
34 |
|
35 ## Author: Kai P. Mueller <mueller@ifr.ing.tu-bs.de> |
|
36 ## Created: November 4, 1997 |
|
37 ## based on is_controllable.m of Scottedward Hodel |
|
38 |
|
39 function Qs = ctrb (sys, b) |
|
40 |
|
41 if (nargin == 2) |
|
42 a = sys; |
|
43 elseif (nargin == 1 && is_struct(sys)) |
|
44 sysupdate(sys,"ss"); |
|
45 [a,b] = sys2ss(sys); |
|
46 else |
|
47 usage("ctrb(sys [, b])") |
|
48 endif |
|
49 |
|
50 if (!is_abcd(a,b)) |
|
51 Qs = []; |
|
52 else |
|
53 ## no need to check dimensions, we trust is_abcd(). |
|
54 [na, ma] = size(a); |
|
55 ## using imb avoids name conflict with the "mb" function |
|
56 [inb, imb] = size(b); |
|
57 Qs = zeros(na, ma*imb); |
|
58 for i = 1:na |
|
59 Qs(:, (i-1)*imb+1:i*imb) = b; |
|
60 b = a * b; |
|
61 endfor |
|
62 endif |
|
63 endfunction |