3432
|
1 ## Copyright (C) 1996 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 |
7016
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
3432
|
9 ## |
7016
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
3432
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
3432
|
18 |
|
19 ## -*- texinfo -*- |
5016
|
20 ## @deftypefn {Function File} {@var{out} =} ltifr (@var{a}, @var{b}, @var{w}) |
|
21 ## @deftypefnx {Function File} {@var{out} =} ltifr (@var{sys}, @var{w}) |
|
22 ## Linear time invariant frequency response of single-input systems. |
|
23 ## |
3432
|
24 ## @strong{Inputs} |
|
25 ## @table @var |
3502
|
26 ## @item a |
|
27 ## @itemx b |
3432
|
28 ## coefficient matrices of @math{dx/dt = A x + B u} |
|
29 ## @item sys |
|
30 ## system data structure |
|
31 ## @item w |
|
32 ## vector of frequencies |
|
33 ## @end table |
5016
|
34 ## @strong{Output} |
|
35 ## @table @var |
|
36 ## @item out |
|
37 ## frequency response, that is: |
|
38 ## @end table |
|
39 ## @iftex |
|
40 ## @tex |
5017
|
41 ## $$ G(j\omega) = (j\omega I-A)^{-1}B $$ |
5016
|
42 ## @end tex |
|
43 ## @end iftex |
|
44 ## @ifinfo |
3432
|
45 ## @example |
|
46 ## -1 |
5016
|
47 ## G(s) = (jw I-A) B |
3432
|
48 ## @end example |
5016
|
49 ## @end ifinfo |
3432
|
50 ## for complex frequencies @math{s = jw}. |
|
51 ## @end deftypefn |
|
52 |
|
53 ## Author: R. Bruce Tenison <btenison@eng.auburn.edu> |
|
54 ## Author: David Clem |
|
55 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
56 ## Created: July 1995 |
|
57 ## updated by John Ingram August 1996 for system format |
|
58 |
|
59 function out = ltifr (a, b, w) |
|
60 |
|
61 if ((nargin < 2) || (nargin > 3)) |
|
62 error("incorrect number of input arguments"); |
|
63 endif |
|
64 |
|
65 if (nargin == 2) |
|
66 sys = a; |
|
67 w = b; |
4030
|
68 if(!isstruct(sys)) |
3432
|
69 error("two arguments: 1st must be a system data structure"); |
|
70 endif |
|
71 |
4030
|
72 if (!isvector(w)) |
3432
|
73 error("w must be a vector"); |
|
74 endif |
|
75 |
|
76 [nn,nz,mm,pp] = sysdimensions(sys); |
|
77 if(mm != 1) error("sys has %d > 1 inputs",mm); endif |
|
78 |
|
79 [a,b] = sys2ss(sys); |
|
80 |
|
81 else |
|
82 |
|
83 if (columns(a) != rows(b)), |
|
84 error("ltifr: A(%dx%d), B(%dx%d) not compatibly dimensioned", ... |
|
85 rows(a), columns(a), rows(b), columns(b)); |
|
86 endif |
|
87 |
|
88 if(columns(b) != 1) |
|
89 error("ltifr: b(%dx%d) must be a single column vector", ... |
|
90 rows(b),columns(b)); |
|
91 endif |
|
92 |
4030
|
93 if (!issquare(a)) |
3432
|
94 error("ltifr: A(%dx$d) must be square.",rows(a),columns(a)) |
|
95 endif |
|
96 |
|
97 endif |
|
98 |
4030
|
99 if (!isvector(w)) |
3432
|
100 error("w must be a vector"); |
|
101 endif |
|
102 |
|
103 ey = eye(size(a)); |
|
104 lw = length(w); |
|
105 out = ones(columns(a),lw); |
|
106 |
|
107 for ii=1:lw, |
|
108 out(:,ii) = (w(ii)*ey-a)\b; |
|
109 endfor |
|
110 endfunction |