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


% Example 3.51 
% 
% Design of quadratic optimal regulator system 
% 
g=[0.5 0; -0.5 1]; 
h=[2; -2]; 
q=[100 0; 0 1]; 
r=[1]; 
[k,p,e]=dlqr(g,h,q,r); 
disp('The optimal feedback gain matrix k is') 
k1=-k(2) 
k2=k(1) 
 
% 
% Step response 
% 
% The close loop state system is denoted as (gc,hc,cc,dc) 
% 
 
gc=g-h*k; 
hc=[0; 1]; 
cc=[1 0]; dc=[0]; 
figure(1) 
v=[0 100 0 1.2]; 
[y,x]=dstep(gc,hc,cc,dc,1,100); 
kk=1:length(y); 
plot(kk,y,'oy',kk,y,'-w') 
axis(v) 
title('Step Response of Servo Control system') 
xlabel('Sample') 
ylabel('Output y=x1') 
figure(2) 
plot(kk,x,'oy',kk,x,'-w') 
title('Step Response Curves for x1,x2') 
xlabel('Sample') 
ylabel('x1, x2')