MATLAB: Pole-Placement State Space


Berikut ini adalah script MATLAB untuk state feedback controller.



clear all, close all, clc;

%% Define the system

A = [1 0 2;
    2 3 0;
    1 2 3]
% the state matrix

B = [1; 0; 0]
% the input vector

eig(A)
% the eigenvalues are
% 4.7511 + 0.0000i
% 1.1244 + 1.0251i
% 1.1244 - 1.0251i
% it is not stable

%% The pole-placement

desiredPoles = -0.5*ones(3,1)
% desired poles = [-0.5; -0.5; -0.5]

K = acker(A,B,desiredPoles)
% determine the gain K
% based on the Ackermann's formula
% yields
% K = [8.5000 13.0156 12.7188]

%% State feedback controller

sys = ss(A-B*K, eye(size(A)), eye(size(A)), eye(size(A)))

eig(sys.a)
% the eigenvalues are
% -0.5000 + 0.0000i
% -0.5000 + 0.0000i
% -0.5000 - 0.0000i

x0 = [0.1; 0.1; 0.1]
% initial state

t = 0:0.01:25;
% the time duration

x = initial(sys,x0,t);
% response of the state-space
% with initial condition x0
% and time duration t

x1 = [1 0 0]*x';
x2 = [0 1 0]*x';
x3 = [0 0 1]*x';
% the state variables


%% Plot the state variables

subplot(3,1,1); plot(t,x1), grid
title('Response to initial condition')
ylabel('x1')

subplot(3,1,2); plot(t,x2), grid
ylabel('x2')

subplot(3,1,3); plot(t,x3), grid
ylabel('x3')
xlabel('t (seconds)')

Berikut ini ialah plot response dari state variable.


Lihat juga tentang.
Kendali state space MATLAB.