1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
## Copyright (C) 1993, 1994, 1995, 2000, 2002, 2004, 2005, 2006, 2007
## John W. Eaton
##
##
## This program is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or (at
## your option) any later version.
##
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING. If not, see
## <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} {} damp (@var{p}, @var{tsam})
## Displays eigenvalues, natural frequencies and damping ratios
## of the eigenvalues of a matrix @var{p} or the @math{A} matrix of a
## system @var{p}, respectively.
## If @var{p} is a system, @var{tsam} must not be specified.
## If @var{p} is a matrix and @var{tsam} is specified, eigenvalues
## of @var{p} are assumed to be in @var{z}-domain.
## @seealso{eig}
## @end deftypefn
## Author: Kai P. Mueller <mueller@ifr.ing.tu-bs.de>
## Created: September 29, 1997.
function damp (p, tsam)
## assume a continuous system
DIGITAL = 0;
if (nargin < 1 || nargin > 2)
print_usage ();
endif
if (isstruct (p))
if (nargin != 1)
error("damp: when p is a system, tsamp parameter is not allowed.");
endif
[aa, b, c, d, t_samp] = sys2ss (p);
DIGITAL = is_digital (p);
else
aa = p;
if (nargin == 2)
DIGITAL = 1;
t_samp = tsam;
endif
endif
if (! issquare (aa))
error ("damp: Matrix p is not square.")
endif
if (DIGITAL && t_samp <= 0.0)
error ("damp: Sampling time tsam must not be <= 0.")
endif
## all checks done.
e = eig (aa);
[n, m] = size (aa);
if (DIGITAL)
printf (" (discrete system with sampling time %f)\n", t_samp);
endif
printf ("............... Eigenvalue ........... Damping Frequency\n");
printf ("--------[re]---------[im]--------[abs]----------------------[Hz]\n");
for i = 1:n
pole = e(i);
cpole = pole;
if (DIGITAL)
cpole = log (pole) / t_samp;
endif
d0 = -cos (atan2 (imag (cpole), real (cpole)));
f0 = 0.5 / pi * abs (cpole);
if (isa (cpole, "single") && abs(imag (cpole)) < eps ("single") ||
! isa (cpole, "single") && abs (imag (cpole)) < eps)
printf ("%12f --- %12f %10f %12f\n",
real (pole), abs (pole), d0, f0);
else
printf ("%12f %12f %12f %10f %12f\n",
real (pole), imag (pole), abs (pole), d0, f0);
endif
endfor
endfunction
|