📄 ex8_1c.m
字号:
%%%%%%%%%%%%%%%%% Example 8.1(c) %%%%%%%%%%%%%%%%% 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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ---- Closed-loop reference & disturbance step responses ----%cleardisp('Example 8.1(c)')Ts = 0.1; % sampling periodGp_s = tf(4,conv([2 1],[0.5 1])); % continuous processH_s = tf(1,[0.05 1]); % continuous sensorGp_z = c2d(Gp_s,Ts,'zoh'); % discrete plant (no sensor)HGp_z = c2d(H_s*Gp_s,Ts,'zoh'); % discrete plant + sensorKP = 1.032; % proportional gain for 20 pct overshoottime = 0:Ts:8; % define time vector for plots %------ reference input - CL transfer fcnT_ref = KP*Gp_z/(1 + HGp_z*KP) % build CL system with reference inputT_ref = minreal(T_ref); % remove any pole-zero cancellationsy_ref = step(T_ref,time); % CL step response to reference input%----- disturbance input - CL transfer fcnT_dist = Gp_z/(1 + HGp_z*KP) % build CL system with disturbance inputT_dist = minreal(T_dist); % remove any pole-zero cancellationsy_dist = step(T_dist,time); % CL step response to disturbance input%-------- plot responsesfigure; plot(time,y_ref,'o',time,y_dist,'+') % plot both responsesxlabel('Time (s)')ylabel('Amplitude')title(['Example 8.1(c) - Resp to step ref (o) and disturbance (+) inputs'])gridhold offtext('Units','norm','Pos',[0.6,0.84],'Str','reference')text('Units','norm','Pos',[0.7,0.74],'Str','disturbance')text('Units','norm','Pos',[0.6,0.20],'Str',['KP = ',num2str(KP)])% steady statey_ref_ss = y_ref(length(time)) % final value for reference input y_dist_ss = y_dist(length(time)) % final value for disturbance input%----- compute prcent OSpct_OS = 100 * (max(y_ref)/y_ref_ss - 1)%%%%%%%%%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -