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


% Example 3.46 
% 
% Design of quadratic optimal regulator system 
% 
a=[0 1 0; 0 0 1; 0 -2 -3]; 
b=[0; 0; 1]; 
c=[1 0 0]; 
d=[0]; 
r=[0.01]; 
q=[100 0 0; 0 1 0; 0 0 1]; 
[k,p,e]=lqr(a,b,q,r); 
disp(' The optimal feedback gain matrix k is') 
k 
% 
% Step response 
% 
% The close loop state system is denoted as (ac,bc,cc,dc) 
% 
k1=k(1); 
ac=a-b*k; bc=b*k1; 
cc=c; dc=d; 
figure(1) 
step(ac,bc,cc,dc) 
title('Step Response of Quadratic Optimal Control system') 
xlabel('Sec') 
ylabel('Output y=x1') 
figure(2) 
[y,x,t]=step(ac,bc,cc,dc); 
plot(t,x,'y') 
title('Step Response Curves for x1,x2,x3') 
xlabel('Sec') 
ylabel('x1, x2, x3') 
figure(3) 
n=length(t); 
r=ones(1,n); 
u=r-k*x'; 
plot(t,u)