Skip to content

Instantly share code, notes, and snippets.

@cpjobling
Created May 4, 2012 15:00
Show Gist options
  • Save cpjobling/2595316 to your computer and use it in GitHub Desktop.
Save cpjobling/2595316 to your computer and use it in GitHub Desktop.
Solving EGLM03 Exam Q4(c) with Matlab using Ackermann's formula for a state observer
%% EGLM03 Exam 2010-11: Q4(c) Correction.
% Define system to be observed (controller canonical form)
A = [-10, -25, 0; 1, 0, 0; 0, 1, 0];
B = [1; 0; 0];
C = [0,1,2];
% Design of an observer using Ackermann's formula
At = A';
Ct = C';
Obs = [Ct, At * Ct, (At)^2 * Ct];
ObsI = inv(Obs)
% Note
ObsI*18 % makes all elements integers
% the desired observer poles alpha_e(s) = s(s + 25)^2 = s^3 + 50s^2 + 625s
alpha_e = At^3 + 50*At^2 + 625*At
% Calculate observer gains (this Ackermann's formula)
Lt = [0, 0, 1] * ObsI * alpha_e
L = Lt'
L * 9
% Note L = 1/9 * [-1000; 1400; -520]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment