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.
回答(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!