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