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

📄 ex7_4.m

📁 离散控制系统设计的MATLAB 代码
💻 M
字号:
%%%%%%%%%%%%%%%%%% Example 7.4 %%%%%%%%%%%%%%%%%%
%   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                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   ----  Parametric variations  ----
%
clear
disp('Example 7.4')

%-------- Part a: discretization ----------------
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

%-------- Part b: set up parameter values --------------
z0 = 0.1:0.05:0.9;                  % range of zeros
K  = 2:0.5:10;                      % range of gains
nz0 = length(z0);                   % number of values in z0 
nK = length(K);                     % number of values in K
tr_mat = zeros(nz0,nK);             % array to store rise time values
Mo_mat = zeros(nz0,nK);             % array to store overshoot values
dtime  = [0:1:60]'*Ts;              % time array from 0 to 6 s

%----- Part c: for loops to apply various control parameter values -----
for ii = 1:nz0
 for jj = 1:nK
  Gcz = tf(K(jj)*[1 -z0(ii)],[1 -7/9*z0(ii)],Ts); % controller 
  T = feedback(Gz*Gcz,1,-1);        % CL transfer function
  y = step(T,dtime);                % step response
  [Mo,tp,tr,ts,ess] = tstats(dtime,y,1);
  tr_mat(ii,jj) = tr;               % store rise times for 3D plotting
  Mo_mat(ii,jj) = Mo;               % store overshoots for 3D plotting
 end
end

%----------- Part d: 3D & contour plots --------------------------
figure
mesh(K,z0,tr_mat)                   % 3D plot of rise time
xlabel('Gain')						% label for x axis
ylabel('Zero location')             % label for y axis
zlabel('Rise time (s)')             % label for z axis
title('3D mesh plot of rise time for Example 7.4')
disp('******>'), pause

figure
mesh(K,z0,Mo_mat)                   % 3D plot of overshoot
xlabel('Gain')					    % label for x axis
ylabel('Zero location')             % label for y axis
zlabel('Percent overshoot')         % label for z axis
title('3D mesh plot of percent overshoot for Example 7.4')
disp('******>'), pause

tr_vals = [0.3 0.4 0.5 0.6 0.7 0.8 1.0 1.2]; % rise-time contour values
figure
[ctr,htr] = contour(K,z0,tr_mat,tr_vals);   % plot rise-time contour lines
clabel(ctr,htr);                            % label rise-time contour lines
grid
xlabel('Gain')
ylabel('Zero location'),hold on
Mo_vals = [10 20 30 40 50 60 70];   % pct overshoot contour values
[cMo,hMo] = contour(K,z0,Mo_mat,Mo_vals,'--'); % plot overshoot contour lines
clabel(cMo,hMo);                               % label overshoot contour lines
plot(7.0, 0.87,'x')                            % X marks a design solution 
set(findobj('marker','x'),'markersize',12)     % ...satisfying Mo<=20 pct
set(findobj('marker','x'),'linewidth',2.0)     % ... & tr <=0.6 s
hold off
title('Contours of rise time and percent overshoot for Example 7.4')
%%%%%%%%%%



 

⌨️ 快捷键说明

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