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