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


% Example 3.33 
% 
% Design of an inverted pendulum control system 
%  using pole placement -- Ackermann 
% 
% Modelling 
a=[0 1 0 0; 20.601 0 0 0; 0 0 0 1; -0.4905 0 0 0]; 
b=[0; -1; 0; 0.5]; 
c=[0 0 1 0]; 
d=[0]; 
a1=[a zeros(4,1);-c 0]; 
b1=[b;0]; 
% Check the controllability 
disp('The rank of controllability matrix') 
rc=rank(ctrb(a1,b1)) 
% Design 
p=[-1+sqrt(3)*i -1-sqrt(3)*i -5 -5 -5]; 
k=acker(a1,b1,p) 
% 
% Step response 
% 
% The close loop state system is denoted as (ac,bc,cc,dc) 
% 
k1=k(1:4); ki=-k(5); 
ac=[a-b*k1 b*ki; -c 0]; 
bc=[0 0 0 0 1]'; 
cc=[c 0]; 
dc=[0]; 
figure(1) 
v=[0 5 -0.4 1.4]; 
step(ac,bc,cc,dc) 
axis(v) 
title('Step Response of inverted pendulum system') 
xlabel('Sec') 
ylabel('Output y=x3') 
figure(2) 
[y,x,t]=step(ac,bc,cc,dc); 
plot(t,x,'y') 
axis(v) 
title('Step Response Curves for x1,x2,x3,x4,x5') 
xlabel('Sec') 
ylabel('x1, x2, x3, x4, x5') 
text(1.2, 0.05, 'x1') 
text(1.2, -0.33, 'x2') 
text(1.2, 0.4, 'x3') 
text(2.2, 0.25, 'x4') 
text(1.5, 1.28, 'x5')