ex3_6.m
来自「离散控制系统设计的MATLAB 代码」· M 代码 · 共 58 行
M
58 行
%%%%%%%%%%%%%%%%%% Example 3.6 %%%%%%%%%%%%%%%%%%
% 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 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---- Feedback connection using a selective output ----
%
clear
disp('Example 3.6')
Ts = 0.05 % sampling time
% enter 1-input/2-output system
G1 = tf(0.01340,conv([1 -0.9394],[1 -0.7788]),Ts)
disp('******>'), pause
G2 = tf(0.2212,[1 -0.7788],Ts)
disp('******>'), pause
G = [G1; G2] % adjoin system
disp('******>'), pause
Gc = 3
% ---- part a: controller in feedback path ------
% Gc connects from output 2 to input 1
Gcla = feedback(G,Gc,1,2)
disp('******>'), pause
Gcla = minreal(Gcla) % eliminate redundent poles and zeros
disp('******>'), pause
dtime = 0:Ts:4; % time vector
ya = step(Gcla,dtime); % step response
figure
plot(dtime,ya(:,1),'o',dtime,ya(:,2),'*');grid % plot y1 & y2
xlabel('Time (s)')
ylabel('Amplitude')
title('Step response with controller in feedback path for Example 3.6')
text(0.3,0.22,'y_2')
text(1.25,0.17,'y_1')
axis([0 4 0 0.3])
% ---- part b: controller in forward path ------
% Gc connects from output 2 to input 1
Gclb = feedback(G*Gc,1,1,2)
disp('******>'), pause
Gclb = minreal(Gclb) % eliminate redundent states
disp('******>'), pause
yb = step(Gclb,dtime); % step response
figure
plot(dtime,yb(:,1),'o',dtime,yb(:,2),'*');grid % plot y1 & y2
xlabel('Time (s)')
ylabel('Amplitude')
title('Step response with controller in forward path for Example 3.6')
text(0.3,0.7,'y_2')
text(1.25,0.5,'y_1')
%%%%%%%%%%
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?