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.
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!