ex7_5.m

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

M
31
字号
%%%%%%%%%%%%%%%%%% Example 7.5 %%%%%%%%%%%%%%%%%%
%   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                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   ----  Position and velocity error constants  ----
%
clear
disp('Example 7.5')

Gp = tf(1,[1 1 0])                  % plant in continuous tf form
Ts = 0.1;                           % sampling time
Gz = c2d(Gp,Ts,'zoh')               % discretization using zero-order hold
Kz = tf(5*[1 -0.9],[1 -0.7],Ts)     % controller in discrete tf form
Kp = dcgain(Gz*Kz)                  % position error constant
Kv = vgain(Gz*Kz)                   % velocity error constant
Ta = feedback(Gz*Kz,1,-1)           % CL transfer function
k  = [0:1:40]';
y  = lsim(Ta,k*Ts,k*Ts);            % simulate system with ramp input

figure
plot(k*Ts,k*Ts,'o'),grid,hold on    % plot ramp input
plot(k*Ts,y,'*'),hold off           % plot ramp response
xlabel('Time (s)')
ylabel('Amplitude')
text(1.0,2.1,'Ramp input')
text(2.6,1.8,'Response')
title('Ramp input and response for Example 7.5')
%%%%%%%%%%

⌨️ 快捷键说明

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