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

📄 lognyq.m

📁 控制系统计算机辅助设计——MATLAB语言与应用(源代码)
💻 M
字号:
function lognyq(re,im,mask,linetype)
%LOGNYQ Nyquist-like plots on logarithmic axes.
%        lognyq(c,mask,linetype)
%        lognyq(re,im,mask,linetype)
%        lognyq(c,linetype),   lognyq(re,im,linetype)
%        lognyq(c,mask),       lognyq(re,im,mask)
%        lognyq(c),            lognyq(re,im)
% Plots Nyquist-like plots of the columns of the complex matrix c,
% or of the columns of the real matrix im versus the columns of re,
% but with a logarithmic transformation of the moduli.
% Only those rows are plotted in which each element has
% modulus >= mask > 0. Elements which have modulus = mask are mapped
% to the origin. The default value of mask is 0.01.
%
% This function is intended for examining the topology of loci which 
% have a large range of moduli. The axis calibrations are difficult
% to interpret correctly except for points which actually lie on 
% the axes: for such points 
%    abs(axis calibration) = log10(abs(point)) - log10(mask)
% so with the default mask the point (-1,0) is mapped to (-2,0).

% J.M.Maciejowski, 30 April 1988. Revised 8 May 1988. Revised 4 May 1989.
% Copyright (c) 1988, Cambridge Control Ltd.
% This version allows 'linetype' as an argument.

nargs=nargin;
error(nargchk(1,4,nargs));
linedef = ' ';  maskdef = 0.01;  % Default values

if nargs == 3,
  if isstr(mask),       % 3rd argument is linetype
    linetype = mask;
    if max(size(im))==1, % 2nd argument is mask
      mask = im;   im = imag(re);   re = real(re);
    else                % 2nd argument is imaginary part
      mask = maskdef;
    end
  else                  % 3rd argument is mask
    linetype = linedef;
  end
end  % of nargs == 3

if nargs == 2,
  if isstr(im),         % 2nd argument is linetype
    linetype = im;   mask = maskdef;
    im = imag(re);   re = real(re);
  elseif max(size(im))==1, % 2nd argument is mask
    linetype = linedef;   mask = im;   
    im = imag(re);   re = real(re);
  else                  % 2nd argument is imaginary part
    linetype = linedef;   mask = maskdef;
  end
end  % of nargs == 2

if nargs == 1,
  linetype = linedef;
  mask = maskdef;
  im = imag(re);
  re = real(re);
end  % of nargs == 1.

[nrows,ncols] = size(re);
if any([nrows,ncols] ~= size(im)),
  error('Matrices re & im must have the same size')
end

[mc,pc] = r2p(re,im);  % Convert to magnitude and phase
mc = mc/mask;          % Scale magnitudes

if ncols > 1,                        % Find and keep those rows
  index = find(all(mc'>= 1));        % which have all moduli >= mask  
else
  index = find(mc'>= 1);
end
mc = mc(index,:); pc = pc(index,:);   

lmc = log10(mc);       % Each element of mc >= 1 by now
[re,im] = p2r(lmc,pc);

if linetype == linedef,
  plot(re,im),grid,xlabel('Real (transformed)'),...
    ylabel('Imag (transformed)'),title('Logarithmic plot')
else
  plot(re,im,linetype),grid,xlabel('Real (transformed)'),...
    ylabel('Imag (transformed)'),title('Logarithmic plot')
end

⌨️ 快捷键说明

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