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

📄 fdiag.m

📁 控制系统计算机辅助设计——MATLAB语言与应用(源代码)
💻 M
字号:
function x=fdiag(w,f,k)
%FDIAG  Diagonal elements of MVFR matrix.
%       FDIAG(W,F,k) returns the kth-diagonal elements,
%       one row per frequency,
%       of the MVFR matrix, F
%       k = 0 is the main diagonal, k > 0 is above
%       k < 0 is below.
%       W is the associated frequency vector.
%
%       The input argument k is optional.
%       If it is missing the default of 0 is used
%       and the main diagonals are returned.
%
%       If the fsize(W,F)=[1,m]
%       Then the rows of F are placed on the kth diagonal of the component
%       matrices of a zero MVFR matrix.

%       Dr M.P. Ford 4th August 1987
% Copyright (c) 1987 by GEC Engineering Research Centre & Cambridge Control Ltd

[m,n]=fsize(w,f);
lw=length(w);
if m==1  % put f into eye(n)
   if nargin < 3
      k=0;
   end
   x=zeros(lw*(n+abs(k)),n+abs(k));
   ind=1:n;
   if k>=0
      ind=[ind;ind+abs(k)]';
   else
      ind=[ind+abs(k);ind]';
   end
   x=fput(w,x,f,ind);
   return    % stop here
end
for i=1:min(m,n)
    ind(i,:)=[i,i];
end
if nargin > 2
  if k>0   % have a k
     ind(:,2)=ind(:,2)+k;
     ind=ind((ind(:,2)<=n),:);
  elseif k<0
     ind(:,1)=ind(:,1)-k;
     ind=ind((ind(:,1)<=m),:);
  end
end
if (length(ind))~=0
   x=fget(w,f,ind);
else
   x=[];
end

⌨️ 快捷键说明

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