MATLAB Answers

Floating Point scalar error while trying to find Grammians

2 views (last 30 days)
hussain askar
hussain askar on 5 Dec 2020
Answered: Shraddha Jain on 22 Dec 2020
This is my code, I'm trying to find the controllability and observability Grammians of the following system where k is unknown. Since i have k, i can't use the function gram(sys,'c'). So i'm trying to use the Grammian equation but i keep getting these errors:
Error using integral (line 85)
A and B must be floating-point scalars.
Error in control (line 15)
Wc = integral(fun,0,T)
Can anyone help me with this please?
syms k tau T
A = [0 1 0; 0 0 1; -6.63*k -171 -101.71];
B = [0;0;6.63*k];
C = [1 0 0];
D = 0;
A_T = A.';
B_T = B.';
C_T = C.';
fun =@(tau) expm(-A*taw).* B .* B_T .* expm(-A_T*taw);
Wc = integral(fun,0,T)
det_Wc = det(Wc)
fun1 = @(tau) expm(A_T*taw) .* C_T .* C .* expm(A*taw);
Wo = integral(fun1,0,T)
det_Wo = det(Wo)

Answers (1)

Shraddha Jain
Shraddha Jain on 22 Dec 2020
Hi Hussain,
You are experiencing this error because k is undefined, as a result, A and B are computed as symbolic variables and not matrices as expected by the function expm.

Community Treasure Hunt

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

Start Hunting!