Problem with ctrbf() and its answer

Hi guys. I have this state-space system and I want to seprate the controllable and uncontrollable parts of this system hence I used ctrbf() my problem is the output doesn't define what is the Ac(Controllable part) and what is the Auc(Uncontrollable part) is..I have tried this code with the k but the problem is Ac and Bc controllablity matrix is not full rank this shows I didn't find Ac and Bc correctly.
%% Staircase controllability form by using ctrbf()
A=[-2 0 0;0 -2 0;0 0 4];
B=[0 0;0 1;1 0];
C = eye(size(A)); %Dummy C matrix :)
[A_bar, B_bar,C_bar,T,k] = ctrbf(A,B,C);
%Extract controllable and uncontrollable subspaces
nc = sum(k);
A_c = A_bar(1:nc, 1:nc); %Controllable part of A
B_c = B_bar(1:nc, :); %Controllable input
A_u = A_bar(nc+1:end, nc+1:end); %Uncontrollable part of A
disp("The controllable part of A is: ")
The controllable part of A is:
disp(A_c)
-2 0 0 -2
disp("The uncontrollable part of A is: ")
The uncontrollable part of A is:
disp(A_u)
4
disp("The controllable B is: ")
The controllable B is:
disp(B_c)
0 0 0 1
Co_staircase = ctrb(A_c, B_c);
if rank(Co_staircase) == rank(A_c)
disp("The controllable sepration was correct")
else
disp("The controllable sepration is not correct")
end
The controllable sepration is not correct
Anyone can help me to correctly find A_c, A_u and B_c??

8 Comments

[A_bar, B_bar,C_bar,T,k] = ctrbf(A,B,C);
%Extract controllable and uncontrollable subspaces
A_u = A_bar(1:k, 1:k); %Controllable part of A
The k that is returned is a vector that can include 0's
Each entry of k represents the number of controllable states factored out during each step of the transformation matrix calculation. The number of nonzero elements in k indicates how many iterations were necessary to calculate T, and sum(k) is the number of states in Ac, the controllable portion of Abar.
You should not be using k as the upper bounds of indexing -- it is a vector not a scalar, and it can include 0's.
Hi but here it doesn't really matter. If we consider k as sum(k) which is the number of controllable states(It's 2 here) we will get the same result. I can't figure out how to find Ac,Au and Bc from A_bar and B_bar
A=[-2 0 0;0 -2 0;0 0 4];
B=[0 0;0 1;1 0];
C = eye(size(A)); %Dummy C matrix :)
[A_bar, B_bar,C_bar,T,k] = ctrbf(A,B,C);
%Extract controllable and uncontrollable subspaces
A_u = A_bar(1:sum(k), 1:sum(k)) %Uncontrollable part of A
A_u = 2×2
-2 0 0 -2
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
A_c = A_bar(sum(k)+1:end, sum(k)+1:end) %Controllable part of A
A_c = 4
B_c = B_bar(1+sum(k):end, :) %Controllable input
B_c = 1×2
-1 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Why would you get the same result? If the number of controllable modes is nc = sum(k), then nc (not k) can be used to properly index into A_bar, B_bar, and C_bar to extract the controllable portion.
I have changed my original code because I have also noticed a mistake in k indexing(A_c was A_u and A_u was A_c) in my first code. nc is total controllable states in Ac so in A_bar, Ac is a square matrix which is (nc*nc)..my problem is Au matrix which is uncontrollable part(I'm not sure about indexing) also as you can see controllability matrix for Ac and Bc is not full rank and hence the Ac and Bc didn't compute correctly so long story short I don't know If I'm computing Ac, Au and Bc correctly or not
Torsten
Torsten on 8 Dec 2024
Edited: Torsten on 8 Dec 2024
Look at my answer. You interchanged the controllable and uncontrollable parts in your code.
I have checked your answer but are you sure the controllable part is +4 and the matrix with -2s is uncontrollable part? +4 is an unstable pole in this system how it can be controllable? Also If we use minreal() which is elimanting the uncontrollable modes we will get this answer(with a dummy D which is zero in all elements):
%% Using minimal realization
A=[-2 0 0;0 -2 0;0 0 4];
B=[0 0;0 1;1 0];
C = eye(size(A)); %Dummy C matrix :)
D = zeros(size(C, 1), size(B, 2)); %Dummy D
sys = ss(A,B,C,D);
min_sys = minreal(sys)
1 state removed. min_sys = A = x1 x2 x1 -2 0 x2 0 4 B = u1 u2 x1 0 1 x2 1 0 C = x1 x2 y1 0 0 y2 1 0 y3 0 1 D = u1 u2 y1 0 0 y2 0 0 y3 0 0 Continuous-time state-space model.
so based on this the controllable part for A shouldn't be: A=[-2 0;0 4]?? also Bc should be [0 1;1 0]?? but again +4 is am unstable pole so I don't understand how minreal thinks it's controllable??
My answer is based on the documentation of "cbrtf". If you think the answer from "cbrtf" is incorrect, you should contact MATLAB support. I have no background knowledge in control theory to answer this.

Sign in to comment.

Answers (1)

Paul
Paul on 8 Dec 2024
Check the doc page ctrbf to see how A_bar etc. are arranged in terms of the uncontrollable and controllable portions.

2 Comments

I have checked that but the doc page is not helping. basically from this page I just figured out that Bc should be something like:[0 1;1 0]. The A_bar that I have claculated can have multiple options for Ac,Au and A12 in doc page since it's a 3* 3 matrix
Paste your current code as a comment response in this answer so we can see where things stand after all of your modifications.

Sign in to comment.

Categories

Products

Release

R2024b

Asked:

on 8 Dec 2024

Commented:

on 8 Dec 2024

Community Treasure Hunt

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

Start Hunting!