hello.
i'm fairly new to MatLab and im trying calculate whether a state-space system is controllable or not and then display it in writing. the question i have is: am i doing it correclty? i've googled a bit trying to figure it out on my own, but since i have little no no experience using the software i'm not getting a definite answer.
my goal is simply to write out whether the system is controlable or not, and im unsure if i've got the syntax correct.
thanks in advance :)
System controlability.
clc, clear, close all;
A=[1 1;-4 -2;]; B=[1 -1;1 -1];
system=ss(A,B,[],[]);
co=ctrb(system)
dimensjon=isequal(A,co);
if(dimensjon==0)
disp('system is not controlable')
else
disp('system is controlable')
end
edit:
i've since updated the code:
  • think it's better, but original question still stands.
System controlability.
clc, clear, close all;
A=[1 1;4 -2]; B=[1 -1;1 -1];
system=ss(A,B,[],[]);
co=ctrb(system);
unco= length(A)-rank(co);
if(unco==0)
disp('system is controlable')
else
disp('system is not controlable')
end

 채택된 답변

Star Strider
Star Strider 2022년 2월 24일

0 개 추천

The example in the documentation section on Check System Controllability is the same test I usually use. It would be appropriate in your application as well.

댓글 수: 4

sverre Kvist
sverre Kvist 2022년 2월 24일
thank you.
so if i continue with:
system=ss(A,B,[],[]);
co=ctrb(system);
unco= length(A)-rank(co);
if(unco==0)
disp('system is controlable')
else
disp('system is not controlable')
end
i could rely on the answer of the if-sentence. the way i understood it is that as long as unco is 0 it is equivalent to det(B AB) !=0.
It is important to remember that this function (and every other one that I am aware of) is subject to the constrints and inaccuracies of floating-point calculations. (See the documentation section on Limitations for details.) It may be necessary to use a tolerance in any test.
A=[1 1;-4 -2;]; B=[1 -1;1 -1];
system=ss(A,B,[],[]);
co=ctrb(system)
co = 2×4
1 -1 2 -2 1 -1 -6 6
unco = length(system.A) - rank(co)
unco = 0
I am not certain that calculating ‘det([system.B system.A*system.B])’ is even possible since:
Test = det([system.B system.A*system.B])
Error using det
Matrix must be square.
I would use the test in the documentation.
.
sverre Kvist
sverre Kvist 2022년 2월 24일
alright. thank you very much for your assistance.
i think i've arrived at a code that works.
for Reference:
clc, clear, close all;
A=[1 1;4 -2]; B=[1 -1;1 -1];
system=ss(A,B,[],[]);
controlabilityMatrix=ctrb(A,B); %Mc=[B, AB]
unco= length(A)-rank(controlabilityMatrix);
if(unco==0)
disp('system is controlable')
else
disp('system is not controlable')
end
Star Strider
Star Strider 2022년 2월 24일
My pleasure!
The code appears to be correct, at least wirh respect to my understanding.
If my Answer helped you solve your problem, please Accept it!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2022년 2월 24일

댓글:

2022년 2월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by