How to Design a Full Order Observer in MATLAB?

162 vues (au cours des 30 derniers jours)
Nick M.
Nick M. le 1 Avr 2019
Commenté : Rik le 7 Déc 2020
Hi, i was wondering what is the proper way to design a full order observer in MATLAB given the state space matrices: A,B,C,D from x_dot=Ax+Bu. Do you have to use the estim, place, reg commands in MATLAB. If so, how do you use them together? An example would be extremely helpful.

Réponses (1)

Aquatris
Aquatris le 1 Avr 2019
Modifié(e) : Aquatris le 1 Avr 2019
place() function is for controller design not related to observers. The function finds a state feedback control law, u = Kx, such that eigenvalues of the closed loop system eig(A-B*K) are placed at the desired values. One usually needs an observer to achieve the state information x, that might me why you might be confused about that.
reg() function combines the observer design and controller design procedures. I am not familiar with the function so I am not so sure on what criteria it uses for the controller design.
For just observer design, I prefer to use kalman function. Here is a simple example with kalman;
% plant model (can be thought of as single mass-spring-damper)
A = [0 1;-4 -0.2];
B = [0 1]';
C = [1 0];
sys = ss(A,B,C,0);
% design observer gain
Q = 3e4; R = 0.01; % covariance of process and sensor noises,
% system specific values, needs tuning
[kest,L,P] = kalman(sys,Q,R,[]);
% assume model used for observer is identical to the plant
Aobs = A;
Bobs = B;
Cobs = C;
% obtain both plant and observer in a single system called sysNew
% first 2 state are plant states, last 2 states are observer states
Anew = [A zeros(2);
L*C Aobs-L*Cobs]; % output of the plant affects the observer
% states due to the way observers work
%first input to the system with observer is the unknown disturbance,
% which only affects the plant not the observer,
% second input is the control input
% both affect the plant the same way (i.e.,force acting on the mass)
Bnew = [B B
zeros(2,1) Bobs];
% first output is plant output,
% last 2 are observer state estimates
Cnew = [C zeros(1,2);
zeros(2,2) eye(2)];
sysNew = ss(Anew,Bnew,Cnew,0);
% see how well the observer estimates the output under step disturbance
t = 0:1e-3:10;
u1 = 2*cos(5*2*pi*t')+2*cos(1*2*pi*t');+2*cos(.2*2*pi*t');; % disturbance
u2 = zeros(length(t),1); % control input
y = lsim(sysNew,[u1 u2],t);
plot(t,y(:,1),t,y(:,2)) % first state of the observer is the position of the mass
legend('plant output','observer output estimate')
Hope this helps.
  2 commentaires
Aquatris
Aquatris le 2 Avr 2019
I think you might have a lack of understanding of the topic. What do you mean by full order observer? The example I gave you is already a full order observer. The example plant has 2 states and the observer estimates those 2 states.Your question is going into the domain of DO IT FOR ME instead of trying to understand how Matlab can be used for your problem.
If you would like to use ode45, you just need replace the lsim part. For this you need to create a function for xdot = Ax+Bu and call the ode45 to solve for x.
Rik
Rik le 7 Déc 2020
Comment posted as answer jingzheng fan:
ok

Connectez-vous pour commenter.

Tags

Produits


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by