7017
|
1 ## Copyright (C) 1993, 1994, 1995, 2000, 2002, 2004, 2005, 2006, 2007 |
|
2 ## John W. Eaton |
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 -*- |
3501
|
21 ## @deftypefn {Function File} {} damp (@var{p}, @var{tsam}) |
3432
|
22 ## Displays eigenvalues, natural frequencies and damping ratios |
5016
|
23 ## of the eigenvalues of a matrix @var{p} or the @math{A} matrix of a |
3432
|
24 ## system @var{p}, respectively. |
|
25 ## If @var{p} is a system, @var{tsam} must not be specified. |
|
26 ## If @var{p} is a matrix and @var{tsam} is specified, eigenvalues |
|
27 ## of @var{p} are assumed to be in @var{z}-domain. |
5642
|
28 ## @seealso{eig} |
3432
|
29 ## @end deftypefn |
|
30 |
|
31 ## Author: Kai P. Mueller <mueller@ifr.ing.tu-bs.de> |
|
32 ## Created: September 29, 1997. |
|
33 |
|
34 function damp (p, tsam) |
|
35 |
|
36 ## assume a continuous system |
|
37 DIGITAL = 0; |
7126
|
38 |
|
39 if (nargin < 1 || nargin > 2) |
6046
|
40 print_usage (); |
3432
|
41 endif |
7126
|
42 |
|
43 if (isstruct (p)) |
3432
|
44 if (nargin != 1) |
|
45 error("damp: when p is a system, tsamp parameter is not allowed."); |
|
46 endif |
7126
|
47 [aa, b, c, d, t_samp] = sys2ss (p); |
|
48 DIGITAL = is_digital (p); |
3432
|
49 else |
|
50 aa = p; |
|
51 if (nargin == 2) |
7126
|
52 DIGITAL = 1; |
|
53 t_samp = tsam; |
3432
|
54 endif |
|
55 endif |
7126
|
56 if (! issquare (aa)) |
|
57 error ("damp: Matrix p is not square.") |
3432
|
58 endif |
|
59 if (DIGITAL && t_samp <= 0.0) |
7126
|
60 error ("damp: Sampling time tsam must not be <= 0.") |
3432
|
61 endif |
|
62 |
|
63 ## all checks done. |
7126
|
64 e = eig (aa); |
|
65 [n, m] = size (aa); |
3432
|
66 if (DIGITAL) |
7126
|
67 printf (" (discrete system with sampling time %f)\n", t_samp); |
3432
|
68 endif |
7126
|
69 printf ("............... Eigenvalue ........... Damping Frequency\n"); |
|
70 printf ("--------[re]---------[im]--------[abs]----------------------[Hz]\n"); |
3432
|
71 for i = 1:n |
|
72 pole = e(i); |
|
73 cpole = pole; |
|
74 if (DIGITAL) |
7126
|
75 cpole = log (pole) / t_samp; |
3432
|
76 endif |
7126
|
77 d0 = -cos (atan2 (imag (cpole), real (cpole))); |
|
78 f0 = 0.5 / pi * abs (cpole); |
|
79 if (abs (imag (cpole)) < eps) |
|
80 printf ("%12f --- %12f %10f %12f\n", |
|
81 real (pole), abs (pole), d0, f0); |
3432
|
82 else |
7126
|
83 printf ("%12f %12f %12f %10f %12f\n", |
|
84 real (pole), imag (pole), abs (pole), d0, f0); |
3432
|
85 endif |
|
86 endfor |
|
87 |
|
88 endfunction |