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

📄 tfn1.m

📁 内模控制器(IMC)工具箱。包括参数整定、PID控制器参数转换等
💻 M
字号:
function [p]=tfn1(k,n,d,td)
% tfn takes a scalar gain, k, matricies n and d, and dead time, td
% to form a single input, single output transfer function, using the rows
% of n and d to form the numerator and denominator polynomials, respectively. 
%
% Example: num=[1 3] 
%          den=[1 2 5;0 1 2]
%          td=6
% g= tfn(5,num,den,td)
%  
% forms:
% 
% g=5(s + 3)/((s^2 + 2s + 5)(s + 2)); with a delay of 6
%
% which is actually written out as: 
%
% 1.5*(0.3333 s + 1)
% ------------------------------
% (.2 s^2 + 0.4 s + 1)*( 0.5 s + 1)
%
% input delay: 6
%
% and as:
%
% Transfer function:
%        5 s + 15
%  ----------------------
%  s^3 + 4 s^2 + 9 s + 10
%
% input delay: 6
%
% Notice that each row of num or den must have the same number of elements.
% Therefore,lower order polynomials must have explicit zero coefficients for
% the higher order terms.
 

[nr,nc]=size(n);
[dr,dc]=size(d);
T=td;
numstr='';
if nr==0
   numstr='';
else
      for i=1:nr
      str_n=['(',poly2str(n(i,:),'s'),')'];
      numstr=[numstr,'*',str_n];
   end
end
denstr=['(',poly2str(d(1,:),'s'),')'];
for i=2:dr;
   str_d=['(',poly2str(d(i,:),'s'),')'];
   denstr=[denstr,'*',str_d];
end
%Form the transfer function in time constant form----------------
%Time Constant From:
%gain*numerator
%--------------exp(-td*s)
%Denomenator
%
disp(' ');
disp('Transfer Function as Entered');
disp(' ');
if nr==0
   numstr=[num2str(k)];
   disp(numstr);
else
   numstr=[num2str(k),numstr];
   disp(numstr);
end
disp('--------------------------------------------------------');
disp(denstr);
disp(' ');
strdelay=['input delay: ',num2str(td)];
disp(strdelay);

a=n(1,:);
b=d(1,:);
for i=2:nr
   a=conv(a,n(i,:));
end
 for i=2:dr
    b=conv(b,d(i,:));
 end
 
   a=k*a;
   p=tf([a],[b],'inputdelay',T);
   tcf1(p); 
   
  

⌨️ 快捷键说明

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