CORRECT THE FOLLOWING MATLAB SCRIPT, error in =untitled3 (line 8) / sys = ss(A, B, C, D); ???
4 ビュー (過去 30 日間)
古いコメントを表示
% Definisikan matriks G
G = [
1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1;
1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1;
0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0;
0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0;
0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1;
];
% Misalkan A, B, C, D adalah matriks untuk sistem ruang keadaan
A = eye(8); % Matriks A identitas ukuran 8x8
B = ones(8, 1); % Matriks B ukuran 8x1 dengan semua elemen 1
C = G; % Menggunakan G sebagai matriks C
D = zeros(size(C, 1), size(B, 2)); % Matriks D ukuran (8x1)
% Buat model ruang keadaan
sys = ss(A, B, C, D); % Buat model ruang keadaan
% Analisis sistem
figure; % Membuat figure baru untuk plot
step(sys); % Analisis respons langkah
title('Respons Langkah Sistem Ruang Keadaan'); % Tambahkan judul
grid on; % Tambahkan grid untuk memperjelas plot
2 件のコメント
Aquatris
2024 年 9 月 25 日
As the answer says, your A matrix defines 8 states. But your C matrix tries to calculate outputs from state 9 to 16, which do not exist.
Sam Chak
2024 年 9 月 25 日
Hi @meoui
The error is caused by a matrix dimension mismatch. However, from the perspective of someone researching dynamics, it is very unlikely that the state matrix A is an identity matrix. If you change the state matrix A, then the input matrix B also needs to be adjusted.
回答 (1 件)
Sandeep Mishra
2024 年 9 月 25 日
Hi Meoui,
Upon reviewing the provided code snippet, it is evident that the matrix 'A' has dimensions of 8x8, while the matrix 'C' has dimensions of 8x16. For the 'ss' State-space model, the number of columns in matrix 'A' and matrix 'C' must match to ensure compatibility.
To resolve this issue, you can modify the matrices by adjusting the number of columns in either 'A' or 'C' to make them consistent.
A feasible approach would be to extract the first 8 columns from matrix 'G' to form matrix ‘C’ as shown below:
C = G(:, 1:8);
Please refer to the following MathWorks Documentation to learn more about ‘ss’ function in MATLAB: https://www.mathworks.com/help/releases/R2024a/control/ref/ss.html#:~:text=C%20is%20an%20Ny%2Dby%2DNx%20real%2D%20or%20complex%2Dvalued%20matrix.
I hope this helps you in resolving the query
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!