EE443 Example 10: Dynamic State Variable Control

Matlab m-file:

%
% File Name: example10.m
%
% Description: M-file showing design and implementation of dynamic
% state variable controller.
%

clear ; clf ; % clear memory and figure

A = [0 1; -5 -8] ; % state matrices
B = [0; 2] ;
C = [1 1] ;

Anew = [0 1 0 0; 0 0 C; 0 0 A(1,:); 0 0 A(2,:)] ;% system model w/error dynamics
Bnew = [0; 0; B] ;

dt = 0.001 ; % simulation time step

% Peform First State Feedback Design 
K = acker(Anew, Bnew, [-1 -2 -2 -20]) % determine feedback gains

x = [0; 0] ; y = C*x ; % initial conditions
inte = 0.0 ; inte2 = 0.0 ; 

tvec = 0.0 ; yvec = 0.0 ; i = 1 ; % define vectors for storing outputs

for t = 0.0:dt:3.0, % loop over time for simulation

yd = 3*t ; % desired output
inte = inte + dt*(y - yd) ; % integral of output error
inte2 = inte2 + dt*inte ; % double integral of error
u = -K*[inte2; inte; x] ; % state controller
xdot = A*x + B*u ; % plant dynamics
x = xdot*dt + x ; % euler integrate dynamics
y = C*x ; % output equation

yvec(i) = y ; tvec(i) = t ; % store output & time into vectors
i = i + 1 ; % increment vector index

end ;

plot(tvec, yvec) ; % plot output with labels
xlabel('time (sec)') ; ylabel('y') ;
title('Output Response of Controlled System') ;
hold on ; plot([0 3], [0 9],'r-.') ; hold off ;
legend('y', 'y_d') ;

Matlab Response:


K = 40.0000 42.0000 9.5000 8.5000

Matlab Plot Generated: