ex7_3.m

来自「离散控制系统设计的MATLAB 代码」· M 代码 · 共 47 行

M
47
字号
%%%%%%%%%%%%%%%%%% Example 7.3 %%%%%%%%%%%%%%%%%%
%   Discrete-Time Control Problems using        %
%       MATLAB and the Control System Toolbox   %
%   by J.H. Chow, D.K. Frederick, & N.W. Chbat  %
%         Brooks/Cole Publishing Company        %
%                September 2002                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   ----  Step-response performance  ----
%
clear
disp('Example 7.3')

Ts = 0.1;                           % sampling time
Gp = tf(1,[1 1 0])                  % plant in continuous tf form
Gz = c2d(Gp,Ts,'zoh')               % discretize using zero-order hold
Gc = tf(5*[1 -0.9],[1 -0.7],Ts)     % discretize controller in tf form
disp('******>'), pause

%----------- Ideal sensor ----------------
Ta = feedback(Gz*Gc,1,-1)           % CL transfer function
k  = [0:1:60]';                     % discrete-time index
ya = step(Ta,k*Ts);                 % step response
[Moa,tpa,tra,tsa,essa] = kstats(k*Ts,ya,1)
disp('******>'), pause

%----------- Slow sensor ----------------
H  = tf(10,[1 10])                  % sensor in continuous tf form
HGz = c2d(H*Gp,Ts,'zoh')            % discretize combined H & Gp
Tb = Gz*Gc/(1+HGz*Gc)               % CL transfer fucntion
Tb = minreal(Tb)                    % eliminate duplicate states
disp('******>'), pause
yb = step(Tb,k*Ts);                 % step response
[Mob,tpb,trb,tsb,essb] = kstats(k*Ts,yb,1)
disp('******>'), pause

figure
plot(k*Ts,ya,'*');grid
hold on
plot(k*Ts,yb,'o')
hold off
axis([0 6 0 1.2])
xlabel('Time (s)')
ylabel('Amplitude')
text(3.5,0.35,'* ==> ideal sensor')
text(3.5,0.25,'o ==> slow sensor')
title('Step responses for Example 7.3')
%%%%%%%%%%

⌨️ 快捷键说明

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