CORRECT THE FOLLOWING MATLAB SCRIPT, error in =untitled3 (line 8) / sys = ss(A, B, C, D); ???
4 views (last 30 days)
Show older comments
% 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 Comments
Aquatris
on 25 Sep 2024
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.
Answers (1)
Sandeep Mishra
on 25 Sep 2024
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 Comments
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!