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

📄 transform.m

📁 Software for design and tuninig of SISO and MIMO contol systems
💻 M
字号:
function [T,M]=transform(A)
% The function finds a transformation matrix T that transform
% a matrix or cell array  A (by column switching)to a matrix M  
% having all diagonal elements = 0 (M = A*T). The rules used
% in this function are: (in the n-th iteration of the for loop)
% - choose the column that has a zero in the n-th row.
% - If there are several columns having the n-th row element = 0,
%   choose the colunm that has least number of zero.(leaving the 
%   other column having more zeros for the next iteration)
% - If there is no column having zero in the n-th row element,
%   send the user an error message.
[m,n]=size(A);
if iscell(A) % take care if A is cell array
   temp=zeros(n,n);
   for i=1:n
      for j=1:n
         temp(i,j)=A{i,j};
      end
   end
A=temp;   
end
A=[A;eye(n)];
sorx=A;
for i=1:n
  temp=find(A(i,:)==0);
  if isempty(temp)
     errordlg('The input dead time matrix is not re-arrangable to have all diagonal elements = 0.',...
           'Error in transform.m');
    break
  elseif length(temp)>1
    index=zeros(1,length(temp));
    for j=1:length(temp)
      tmp=find(A(1:n,temp(j))==0);
      index(j)=length(tmp);
    end
    [tmp1,tmp2]=min(index);
    sorx(:,i)=A(:,temp(tmp2));
    A(:,temp(tmp2))=[];
  else
    sorx(:,i)=A(:,temp);
    A(:,temp)=[];
  end
end
M=sorx(1:m,:);
T=sorx(m+1:end,:);

⌨️ 快捷键说明

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