3432
|
1 ## Copyright (C) 1993, 1994, 1995 John W. Eaton |
|
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} {} 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; |
|
38 if(nargin < 1 || nargin > 2) |
|
39 usage("damp(p,[ tsamp])") |
|
40 endif |
4030
|
41 if(isstruct(p)) |
3432
|
42 if (nargin != 1) |
|
43 error("damp: when p is a system, tsamp parameter is not allowed."); |
|
44 endif |
|
45 [aa, b, c, d, t_samp] = sys2ss(p); |
|
46 DIGITAL = is_digital(p); |
|
47 else |
|
48 aa = p; |
|
49 if (nargin == 2) |
|
50 DIGITAL = 1; |
|
51 t_samp = tsam; |
|
52 endif |
|
53 endif |
4030
|
54 if (!issquare(aa)) |
3432
|
55 error("damp: Matrix p is not square.") |
|
56 endif |
|
57 if (DIGITAL && t_samp <= 0.0) |
|
58 error("damp: Sampling time tsam must not be <= 0.") |
|
59 endif |
|
60 |
|
61 ## all checks done. |
|
62 e = eig(aa); |
|
63 [n, m] = size(aa); |
|
64 if (DIGITAL) |
|
65 printf(" (discrete system with sampling time %f)\n", t_samp); |
|
66 endif |
|
67 printf("............... Eigenvalue ........... Damping Frequency\n"); |
|
68 printf("--------[re]---------[im]--------[abs]----------------------[Hz]\n"); |
|
69 for i = 1:n |
|
70 pole = e(i); |
|
71 cpole = pole; |
|
72 if (DIGITAL) |
|
73 cpole = log(pole) / t_samp; |
|
74 endif |
|
75 d0 = -cos(atan2(imag(cpole), real(cpole))); |
|
76 f0 = 0.5 / pi * abs(cpole); |
|
77 if (abs(imag(cpole)) < eps) |
|
78 printf("%12f --- %12f %10f %12f\n", |
|
79 real(pole), abs(pole), d0, f0); |
|
80 else |
|
81 printf("%12f %12f %12f %10f %12f\n", |
|
82 real(pole), imag(pole), abs(pole), d0, f0); |
|
83 endif |
|
84 endfor |
|
85 |
|
86 endfunction |