How can i solve Algebraic Ricatti Equation for SDRE controller?
Show older comments
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
on 26 Nov 2017
Edited: burak ergocmen
on 8 Dec 2017
Victory Friday
on 31 Jan 2022
Please sir, is there a way out in ordering the eigenvalues for script?
Answers (0)
Categories
Find more on Matrix Computations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!