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

📄 ep8_1.m

📁 离散控制系统设计的MATLAB 代码
💻 M
字号:
%%%%%%%%%%%% Exploratory problem 8.1 %%%%%%%%%%%%%   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                 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   ---- PID controller design ----%cleardisp('Exploratory Problem 8.1')Ts = 0.05;	             		    % sampling periodGp_s = tf(500*[1 10],conv(conv([1 2],[1 5]),conv([1 6 25],[1 20])));                                    % continuous processG_z = c2d(Gp_s,Ts,'zoh');	        % discrete plant (no sensor)dtime  = 0:Ts:4;KI = 2.0;symbols = ['o' '+' '*' 'd' 'v'];    % different plot symbolsfor KD = 0.1:0.1:0.4,  figure  results = [];  Pgains = [];  hold on  for ii = 1:5,		                % KP values are: 1.1, 1.2, 1.3, 1.4, 1.5    KP = 1.1+0.1*ii;    %-- write Gc(z) as sum of 3 LTI objects in TF form --    Gc = KP*(tf(1,1,Ts) ...			% porportional	+ tf([KI*Ts  0],[1 -1],Ts) ...	% integral	+ tf(KD*[1 -1],[Ts 0],Ts)); 	% derivative    % reference input - CL transfer fcn    Tref_z = feedback(G_z*Gc,1);    y = step(Tref_z,dtime);         % CL response to step input    ref = dcgain(Tref_z);    [Mo,tpeak,trise,tsettle,ess] = kstats(dtime,y,ref);    ymax = y(find(dtime == tpeak));    yss = y(length(dtime));    results = [results; [KP KD trise tpeak tsettle  Mo]];    Pgains = [Pgains KP];    disp(['KP = ',num2str(KP)])    plot(dtime,y,symbols(ii))    pause(1)  end  % for ii..  hold off                            xlabel('Time (s)')  ylabel('Step Response')  title(['EP8.1 - Step Responses for Different ',...        'Values for KP, where KI = ',num2str(KI),...        ' and KD = ',num2str(KD)])   grid on  text('Units','norm','Pos',[0.2,0.15],'Str',['KI = ',num2str(KI)])  text('Units','norm','Pos',[0.2,0.10],'Str',['KD = ',num2str(KD)])  legend('KP = 1.1','KP = 1.2','KP = 1.3','KP = 1.4','KP = 1.5')    %----- print results table  disp(['KI = ',num2str(KI),' and KD = ',num2str(KD)])   disp(' ')  disp('      KP       KD     t_rise      t_peak      tsettle     M_o (pct)')  disp('    ---------------------------------------------------------------')  disp(results)  disp('    ---------------------------------------------------------------')  disp(' ')end  % for KD..disp('A good choice is KI = 2, KP = 1.4, and KD = 0.3')disp('Completed EP8.1')%%%%%%%%%%

⌨️ 快捷键说明

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