⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ddamp.m

📁 数字通信第四版原书的例程
💻 M
字号:
function [magout,wn,z] = ddamp(a,Ts)
%DDAMP	Natural frequency and damping factor for discrete systems.
%	[MAG,Wn,Z] = DDAMP(A,Ts) returns vectors MAG, Wn and Z containing
%	the z-plane magnitude, and the equivalent s-plane natural 
%	frequency and damping factors of A.  Ts is the sample time.  The
%	variable A can be in one of several formats:
%		1) If A is square, it is assumed to be the state-space
%		   "A" matrix.
%		2) If A is a row vector, it is assumed to be a vector of
%		   the polynomial coefficients from a transfer function.
%		3) If A is a column vector, it is assumed to contain
%		   root locations.
%
%	Without the sample time, DDAMP(A) returns the magnitude only.  
%	When invoked without left hand arguments DDAMP prints the 
%	eigenvalues with their magnitude, natural frequency and damping
%	factor in a tabular format on the screen.
%
%	For a discrete system eigenvalue, lambda, the equivalent s-plane
%	natural frequency and damping ratio are
%
%		Wn = abs(log(lamba))/Ts    Z = -cos(angle(log(lamba)))
%
%	See also: EIG and DAMP.

%	Clay M. Thompson  7-23-90
%	Copyright (c) 1986-93 by the MathWorks, Inc.

error(nargchk(1,2,nargin));

[m,n] = size(a);
if (m == n)
	r = dsort(eig(a));
elseif (m == 1)
	r = dsort(roots(a));
elseif (n == 1)
	r = a;
else
	error('Must be a vector or a square matrix.');
end
mag = abs(r);

if nargin==2,	% If sample time is given solve for equivalent s-plane roots
  s = log(r)/Ts;
  wn = abs(s);
  z = -cos(atan2(imag(s),real(s)));
else
  s = [];
  wn = [];
  z = [];
end

if nargout==0,		% Print results on the screen.
  disp('')
  if nargin==2,
    disp('   Eigenvalue        Magnitude      Equiv. Damping   Equiv. Freq. (rad/sec)')
  else
    disp('   Eigenvalue        Magnitude')
  end
  disp('')
  disp([r,mag,z,wn])

  return % Suppress output
end
magout = mag; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -