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


% Example 3.39 
% 
% 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]; 
% Discretization 
[g,h]=c2d(a,b,0.1); 
g1=[g zeros(4,1);-c*g 1]; 
h1=[h;-c*h]; 
% Check the controllability 
disp('The rank of controllability matrix') 
rc=rank(ctrb(g1,h1)) 
 
% Design 
p=[0.9+0.25*i 0.9-0.25*i 0 0 0]; 
k=acker(g1,h1,p); 
k1=k(1:4), ki=-k(5) 
% 
% Step response 
% 
% The close loop state system is denoted as (ac,bc,cc,dc) 
% 
gc=[g-h*k1 h*ki; -c*g+c*h*k1 1-c*h*ki]; 
hc=[0 0 0 0 1]'; 
cc=[c 0]; 
dc=[0]; 
figure(1) 
[y,x]=dstep(gc,hc,cc,dc,1,100); 
kk=1:length(y); 
plot(kk,y,'o',kk,y,'-') 
title('Step Response of inverted pendulum system') 
xlabel('Samples') 
ylabel('Position of Cart y=x3') 
figure(2) 
hold on 
for j=1:5 
y1=x(:,j); 
plot(kk,y1) 
end 
grid on 
title('Step Response Curves for x1,x2,x3,x4,x5') 
xlabel('Samples') 
ylabel('x1, x2, x3, x4, x5') 
hold off