leaddesign.m
来自「其中提到遺傳學的程式碼與應用提供給次淚相向的研究者參考下載」· M 代码 · 共 49 行
M
49 行
function Lead=LeadDesign(Kp,Kv,PM,plant);
%% Use of a simple lead to compensate for a control system.
%% See P.696 of Nise's Control Systems Engineering,
%% Wiley, 3rd Edition, 2000.
%% For Example:
%Kp=[];Kv=30;PM=30;LeadDesign(Kp,Kv,PM,tf(1,[1 1 0]))
%%
%% PenChen Chou. 2003-5-9
s=tf('s');
% If Kp is empty the use Kv to find K
if ~isempty(Kp)
[num,den]=tfdata(plant,'v');
N=length(num);D=length(den);Limit=num(N)/den(D);
K=Kp/Limit;
else
P1=plant*s; P1=minreal(P1);
[num,den]=tfdata(P1,'v');
N=length(num);D=length(den);Limit=num(N)/den(D);
K=Kv/Limit;
end
% K must be finite
if K<inf
[Gm,Pm,wcg,wcp]=margin(K*plant);
MorePhase=(PM-Pm+7)/57.3;
alpha=(1-sin(MorePhase))/(1+sin(MorePhase));
NewCrossOver=1.2*wcp;
tau=1/NewCrossOver/sqrt(alpha);
Gc=K*(tau*s+1)/(alpha*tau*s+1);
open2=Gc*plant;open1=K*plant;
figure(2);bode(open1,open2);grid;ylabel('Figure 2');
figure(3);margin(open2);ylabel('Figure 3');
clo=open2/(1+open2);clo=minreal(clo);
figure(4);subplot(211);step(clo);ylabel('Figure 4');
figure(4);subplot(212);step(clo);ylabel('Figure 4');
if Kv>0
[y,t]=step(clo);
[y]=lsim(clo,t,t);N=length(y);Ess=t(N)-y(N);
subplot(212);plot(t,t,t,y);grid;
title(['Ramp response with Ess=' num2str(Ess)]);
xlabel('Time (sec.)');
end
else
error('===>Simple Lead compensator wouldnot work for this case.');
end
fprintf('Figure 2 shows the Bode plots of uncompensated and compensated systems\n');
fprintf('Figure 3 shows GM, PM of the compensated systems\n');
fprintf('Figure 4 shows the Time Responses of the compensated systems\n');
Lead=Gc;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?