Kalman decomposition in symbolic value

6 次查看(过去 30 天)
i need to print a kalman decomposition of a system but in symbokic values.
for example
if i write:
m1 = 1;
m2 = 2;
m3 = 3;
k0 = 100;
k1 = 100;
A = [0 0 0 1 0 0;
0 0 0 0 1 0;
0 0 0 0 0 1;
-(k0/m1) (k0/m1) 0 0 0 0;
(k0/m2) -(2*k0/m2) (k0/m2) 0 0 0;
0 (k0/m3) -(k0/m3) 0 0 0];
B = [1/m1; 0; 0; 0; 0; 0];
C = [0 1 0 0 0 0];
D = 0;
%[At,Bt,Ct,T,K]=obsvf(A,B,C)
[At,Bt,Ct,T,K]=ctrbf(A,B,C)
and it works but i need in symbolic value so i add
syms m1 m2 m3 k0 k1;
but i have an error.
how can i solve it?
or someone can send me a script contain how to use Kalman decomposition in symbolic value.
  2 个评论
Dyuman Joshi
Dyuman Joshi 2023-8-30
"but i have an error."
Please copy and paste the full error message you get, i.e. all of the red text.
Also, note that the functions obsvf and ctrbf are part of the Control System Toolbox.
Do you have access to the Control System Toolbox?
Edoardo Moroni
Edoardo Moroni 2023-8-30

This is the error when I call syms without putting the parameters

请先登录,再进行评论。

采纳的回答

MYBLOG
MYBLOG 2023-8-30
Hello,
It seems like you're on the right track! To perform Kalman decomposition with symbolic values, you need to make a few adjustments to your code. Here's how you can achieve that:
% Define symbolic variables
syms m1 m2 m3 k0 k1;
% Define symbolic matrices
A = [0 0 0 1 0 0;
0 0 0 0 1 0;
0 0 0 0 0 1;
-(k0/m1) (k0/m1) 0 0 0 0;
(k0/m2) -(2*k0/m2) (k0/m2) 0 0 0;
0 (k0/m3) -(k0/m3) 0 0 0];
B = [1/m1; 0; 0; 0; 0; 0];
C = [0 1 0 0 0 0];
D = 0;
% Convert matrices to symbolic
A_sym = sym(A);
B_sym = sym(B);
C_sym = sym(C);
% Define symbolic identity matrix
I = sym(eye(size(A_sym)));
% Define the symbolic polynomial matrix for controllability
p_matrix = [B_sym A_sym*B_sym A_sym^2*B_sym A_sym^3*B_sym A_sym^4*B_sym A_sym^5*B_sym];
% Calculate the rank of the polynomial matrix
rank_original = rank(p_matrix);
% Check controllability
if rank_original == numel(A)
disp('The system is controllable.');
else
disp('The system is not fully controllable.');
end
% Define the symbolic polynomial matrix for observability
q_matrix = [C_sym; C_sym*A_sym; C_sym*A_sym^2; C_sym*A_sym^3; C_sym*A_sym^4; C_sym*A_sym^5];
% Calculate the rank of the polynomial matrix
rank_original_obs = rank(q_matrix);
% Check observability
if rank_original_obs == numel(A)
disp('The system is observable.');
else
disp('The system is not fully observable.');
end
I hope this helps you achieve your goal of printing Kalman decomposition with symbolic values. For more details, you can check out the discussion in this thread.
Best regards.
  2 个评论
Edoardo Moroni
Edoardo Moroni 2023-8-30
编辑:Edoardo Moroni 2023-8-30
Thanks for your help put when I put your code, the system print the following matrix are this the right for a kalman decomposition because I need this to study a 3 mass non linear system ?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by