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

📄 ex9_2a.m

📁 离散控制系统设计的MATLAB 代码
💻 M
字号:
%%%%%%%%%%%%%%%% Example 9.2(a) %%%%%%%%%%%%%%%%%
%   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                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   ---- Determination of Klag, alpha, and w_c ----
%
clear
disp('Example 9.2(a)')

tauP1 = 2; tauP2 = 0.5; tau_sen = 0.05; Kproc = 4; % parameters
Gp = tf(Kproc,conv([tauP1 1],[tauP2 1]));          % plant Gp(s)
H  = tf(1,[tau_sen 1]);                            % sensor H(s)
GH = H*Gp     % OL transfer function is plant * sensor in s-domain
Ts = 0.1                                           % sampling period
GHz = c2d(GH,Ts,'zoh')                             % discretization
disp('******>'), pause
[zGHz,pGHz,kGHz] = zpkdata(GHz,'v')                % zeros, poles, & gain of GH(z)
disp('******>'), pause
GHw = d2c(GHz,'tustin')                            % bilinear transform 
disp('******>'), pause
[zGHw,pGHw,kGHw] = zpkdata(GHw,'v')                % zeros, poles, & gain of GH(w)
disp('******>'), pause

%-------------- open-loop frequency response
ww = logspace(-1,1,100)';         % use 100 points for better resolution
[mag_db,ph] = bodedb(GHw,ww);     % compute magnitude & phase as 1:1:100 arrays
mag_ratio = 10.^(mag_db/20);      % convert from db to ratio
%-------- display table of index, phase, mag, & freq values
%           by selecting -135 <= phase <= -115 deg
disp('  Index      phase    magnitude  frequency')
disp('             (deg)                (rad/s)')
for ii = find((ph <= -115)& (ph >= -135)),   
  disp([ ii  ph(ii)  mag_ratio(ii)  ww(ii)]) 
end 
disp('******>'), pause
%--- interpolate to get magnitude for 55 deg phase margin
mag125 = interp1(ph,mag_ratio,-125) 
Klag = 1/mag125                  % set gain for selected phase 
lfg = Klag*dcgain(GHw)           % lfg for plant + gain
Alag = 49/lfg                    % lag alpha supplies rest of req'd low-freq gain
wwc = interp1(ph,ww,-125)

figure
bode(GHw,ww),grid                % plot open-loop frequency response
%%%%%%%%%%

⌨️ 快捷键说明

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