Kalman decomposition in symbolic value
20 次查看(过去 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.
采纳的回答
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Computations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!