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

📄 config.m

📁 基于MATLAB的辅助设计 简述了矩阵分析的重要性
💻 M
字号:
%
% CONFIG  This M-file is used to get the Rational Transfer Function
%     Model required by the user.  ID is the model code.  CLOOP is the
%     identifier so that 
%        CLOOP = 0 for a open loop system
%        CLOOP = 1 for a closed loop system with given feedback
%        CLOOP = 2 for a closed loop system with unity feedback
%
%     <1> If there is no time delay, (NUM,DEN) stores the original system
%        model (When ID <= 9) or compensated system model ( When ID > 9);
%        (NUMX,DENX) stores the uncompensated system model if ID > 9, else
%        it is an empty array pair.
%     <2> If there is a time delay, then, for closed loop systems, 
%        (NUM,DEN) and (NUMX,DENX) are used to store open loop models.        
%
%     If time response is required, and there is a pure time delay
%     in the system, then Pade approximation is used.      
%     
%     When analysing stepresponses, the m-file can return the
%     transferfunction of the output, the error and  the control signal

%    Author:  Ole Barup Sorensen, Rapid Data Ltd 

%    Copyright (c) 1989-94 by Rapid Data Ltd
%    Revision 10:36  07/02/94

cloop = 0;

if id <= 9, numx = [];  denx = [];  end
np = 1; dp = 1;
if (t_delay ~= 0 & (an_type == 6 | an_type == 7)),
[np,dp]=pade(t_delay,3);
%   np = [ -t_delay^3 12*t_delay*t_delay -60*t_delay 120];
%   dp = [  t_delay^3 12*t_delay*t_delay  60*t_delay 120];
end
 
 % Get the Transfer function for open loop of G(s)
if id == 1
   if ptype == 1,
     num = G_num;den = G_den;
   else
     num = 1;den = 1;
   end

 % Get the Transfer function for open loop of Gc(s)
elseif id == 2
   if ptype <= 2,
     num = Gc_num; den = Gc_den;
   else
     num = 1; den = 1;
   end 
 % Get the Transfer function for open loop of Gc(s)G(s)
elseif id == 3
   if ptype == 1,
     num = conv(G_num,Gc_num); den = conv(G_den,Gc_den); 
   elseif ptype ==2,
     num = Gc_num; den = Gc_den;
   else
     num = 1; den = 1;
   end 

 % Get the Transfer function for open loop of G(s)H(s)
elseif id == 4
   if ptype == 1,
     num = conv(G_num,H_num); den = conv(G_den,H_den);
   else
     num = 1;den = 1;
   end

 % Get the Transfer function for open loop of Gc(s)G(s)H(s)
elseif id == 5
   if ptype == 1,
     num = conv(conv(G_num,Gc_num),H_num); 
     den = conv(conv(G_den,Gc_den),H_den);
   elseif ptype == 2,
     num = Gc_num; den = Gc_den;
   else
     num = 1;den = 1;
   end

 % Get the Transfer function for closed loop of G(s)
elseif id == 6
   if ptype == 1,
     num = conv(G_num,dp);
   elseif ptype == 2,
     num = conv(G_den,dp);
   else
     num = conv(G_den,dp);
   end
   cloop = 2;
   if (t_delay == 0 | an_type == 6 | an_type == 7),
      den =addpoly(conv(G_den, dp),conv(np, G_num));
   else
      den = G_den;
   end

 % Get the Transfer function for closed loop of Gc(s)G(s)
elseif id == 7
   if ptype == 1,
     num = conv(G_num,conv(Gc_num,dp));
   elseif ptype == 2,
     num = conv(G_den,conv(Gc_num,dp));
   else
     num = conv(G_den,conv(Gc_den,dp));
   end
   cloop = 2;
   if ( t_delay == 0 | an_type == 6 | an_type == 7),
      den = addpoly(conv(conv(dp,G_den),Gc_den),conv(conv(np,G_num),Gc_num));
   else     
      den = conv(G_den,Gc_den); 
   end

 % Get the Transfer function for closed loop of G(s)H(s)
elseif id == 8
   if ( t_delay == 0 | an_type == 6 | an_type == 7),
      if ptype == 1,
        num = conv(G_num,conv(H_den,dp));
      elseif ptype == 2,
        num = conv(G_den,conv(H_den,dp));
      else
        num = conv(G_den,conv(H_den,dp));
      end
      den = addpoly(conv(conv(dp,G_den),H_den),conv(conv(np,G_num),H_num));
   else
      if ptype == 1,
        num = G_num;
      elseif ptype == 2,
        num = 1;
      else
        num = 1;
      end
      den = G_den; 
   end
   cloop = 1;

 % Get the Transfer function for close loop of Gc(s)G(s)H(s)
elseif id == 9
   if ( t_delay == 0 | an_type == 6 | an_type == 7 ),
      if ptype == 1,
        num = conv(conv(G_num,conv(dp,Gc_num)),H_den);
      elseif ptype == 2,
        num = conv(conv(G_den,conv(dp,Gc_num)),H_den);
      else
        num = conv(conv(G_den,conv(dp,Gc_den)),H_den);
      end
      den = addpoly(conv(conv(conv(np,G_num),Gc_num),H_num) , ...
            conv(conv(conv(dp,G_den),Gc_den),H_den));
   else
      if ptype == 1,
        num = conv(G_num,Gc_num);
      elseif ptype == 2,
        num = Gc_num;
      else
        num = 1;
      end
      den =conv(G_den,Gc_den);
   end
   cloop = 1;

 % Get the TF of both G(s) and Gc(s)G(s)   (open loop)
elseif id == 10
   if ptype == 1,
     numx = G_num; denx = G_den;
     num = conv(G_num,Gc_num); den = conv(G_den,Gc_den);
   elseif p_type == 2,
     numx = 1; denx = 1;
     num = Gc_num; den = Gc_den;
   else
     numx = 1; denx = 1;
     num = 1; den = 1;
   end
 % Get the TF of both G(s) and Gc(s)G(s)   (closed loop)
elseif id == 11
   if ptype == 1,
     numx = conv(G_num,dp);
     num = conv(G_num,conv(Gc_num,dp));
   elseif ptype == 2,
     numx = conv(G_den,dp);
     num = conv(G_den,conv(Gc_num,dp));
   else
     numx = conv(G_den,dp);
     num = conv(G_den,conv(Gc_num,dp));
   end
   cloop = 2;
   if ( t_delay == 0 | an_type == 6 | an_type == 7 ),
      denx = addpoly(conv(G_num,np),conv(G_den, dp));
      den = addpoly(conv(conv(np,G_num),Gc_num),conv(conv(dp,G_den),Gc_den));
   else
      denx = G_den; den = conv(G_den,Gc_den); 
   end

 % Get the TF of both G(s)H(s) and Gc(s)G(s)H(s)   (open loop)
elseif id == 12
   if ptype == 1,
     numx = conv(G_num,H_num); denx = conv(G_den,H_den);
     num = conv(conv(G_num,Gc_num),H_num);den = conv(conv(G_den,Gc_den),H_den);
   elseif ptype == 2,
     numx = 1; denx = 1;
     num = Gc_num; den = Gc_den;
   else
     numx = 1; denx = 1;
     num = 1; den = 1;
   end
 % Get the TF of both G(s)H(s) and Gc(s)G(s)H(s)   (closed loop)
elseif id == 13
   if ( t_delay == 0 | an_type == 6 | an_type == 7 ),
      if ptype == 1,
        numx = conv(G_num,conv(H_den,dp));
        num = conv(conv(G_num,conv(dp,Gc_num)),H_den);
      elseif ptype == 2,
        numx = conv(G_den,conv(H_den,dp));
        num = conv(conv(G_den,conv(dp,Gc_num)),H_den);
      else
        numx = conv(G_den,conv(H_den,dp));
        num = conv(conv(G_den,conv(dp,Gc_num)),H_den);
      end
      denx = addpoly(conv(conv(dp,G_den),H_den),conv(conv(np,G_num),H_num));
      den = addpoly(conv(conv(np,conv(G_num,Gc_num)),H_num), ...
           conv(conv(dp,conv(G_den,Gc_den)),H_den));
   else
      if ptype == 1,
        numx = G_num;
        num = conv(G_num,Gc_num);
      elseif ptype == 2,
        numx = 1;
        num = Gc_num;
      else
        numx = 1;
        num = 1;
      end
      den = G_den; 
      den = conv(G_den,Gc_den);
   end
   cloop = 1;
end
np = length(den);
dp = length(num);
num=[zeros(1,np-dp) num];
if id > 9,
  np=length(denx);
  dp = length(numx);
  numx=[zeros(1,np-dp) numx];
end
if exist('np') == 1, clear np dp; end


⌨️ 快捷键说明

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