How can i solve Algebraic Ricatti Equation for SDRE controller?

7 views (last 30 days)
I have a model in simulink. I use SDRE controller for that model . I can obtain SDC matrices(A(x) and B(x)) by matlab function in simulink . One of the example in simulink matlab function is :
function P = fcn(u,w)
%#codegen
B = [ 0 2 2 0 ;
1 0 0 3 ;
0 4 5 0 ;
0 0 3 0 ;
0 4 0 0 ] ;
A = [2 0 4 u 0 ;
0 5 0 0 0 ;
6 0 7 w 0 ; 1 0 0 0 0 ; 0 1 0 0 0 ] ;
Q= diag([0.6 0.6 0.6 2.6 0.5]);
R= diag([0.00001 1000 1000 1000]);
n = size(A,1);
P = zeros(n,n);
H = [A -(B/R)*B'; -Q -A'];
[T,L] = eig(H);
lambda = diag(L);
ord_lambda = zeros(1,2*n);
for k = 1 : 2*n;
if real(lambda(k)) < 0
ord_lambda(k) = -1;
elseif real(lambda(k)) > 0
ord_lambda(k) = 1;
else
%disp('!!!');
end
end
[~, ord_index] = sort(ord_lambda, 'descend');
T_ord = T(:,ord_index);
T22 = T_ord(n+1:2*n,n+1:2*n);
T12 = T_ord(1:n,n+1:2*n);
P = real(T22/T12);
  2 Comments
burak ergocmen
burak ergocmen on 26 Nov 2017
Edited: burak ergocmen on 8 Dec 2017
1. The ARE can be solved by some methods .These are iterative and numerical ways. Iterative is the best but numerical is also work well. Some numerical example : Schur decomposition of Hamiltonian matrix , Spectral Factorization Some Iterative example : Matrix sign function 2. For real time application of solving algebraic ricatti equation for SDRE controller there are some ways one of that is using S-function (write codes in C programming and use it in the simulink block). There is a really good thesis about that, also there is C codes in thesis : "ANALYSIS AND REAL-TIME IMPLEMENTATION OF STATE-DEPENDENT RICCATI EQUATION CONTROLLED SYSTEMS-EVRIN BILGE ERDEM " another way is using matlab function in Simulink environment . Some functions does not work but i found one of that which is working but some calculation problems which about re ordering schur decomposition (all eigenvalues have to be in the upper triangle of the schur matrix). I post it in here because "[U_ordered,S_ordered] = ordschur(U,S,'lhp')" code does not work in script.So if anybody have an idea pls post it in here These matlab codes are about schur decomposition of hamiltonian matrix . A and B can easily convertible to SDC matrices which shows the system dynamics
function y = fcn(x1,x2)
A = [x1 x2; x1 x2];
B = [2; 1];
C = eye(2);
D = [0; 0];
Q = [1 1; 3 0];
R = [3];
H = [A -(B*inv(R)*B'); -Q -A'];
[U, S] = schur(H);
[m,n] = size(U);
U11 = U(1:(m/2), 1:(n/2));
U21 = U((m/2+1):m, 1:(n/2));
P = U21*inv(U11) ;
y = P;
Victory Friday
Victory Friday on 31 Jan 2022

Please sir, is there a way out in ordering the eigenvalues for script?

Sign in to comment.

Answers (0)

Categories

Find more on Matrix Computations in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!