www.pudn.com > controlsystem.ZIP > EX3048.M


% Example 3.48 
% 
% Design of quadratic optimal regulator system 
% 
a=-diag([0.2 0.5 14.3 33.3 10])+diag([0.5 1.6 85.8 100],1); 
b=[0 0 0 0 30]'; 
c=[1 0 4 3 2]; d=[0]; 
q=diag([1,1,1,1,1]); r=1; 
 
% Design with basic functions of MATLAB 
tol=1e-10; 
k1=1; 
I=eye(size(a)); 
while(1) 
 a0=a-b*k1*c; 
 p=lyap(a0',c'*k1*r*k1*c+q); 
 z=lyap(a0,I); 
 k0=inv(r)*b'*p*z*c'*inv(c*z*c'); 
 if (norm(k0-k1,1)>tol), k1=k0; else break; end 
end 
disp(' The optimal feedback gain matrix k is') 
k=k0 
 
% 
% Step response 
% 
% The close loop state system is denoted as (ac,bc,cc,dc) 
% 
ac=a-b*k*c; 
bc=b; 
cc=c; dc=d; 
figure(1) 
step(ac,bc,cc,dc) 
title('Step Response of Quadratic Optimal Control system') 
xlabel('Sec') 
ylabel('Output y(t)') 
axis([0 0.3 0 1])