CORRECT THE FOLLOWING MATLAB SCRIPT, error in =untitled3 (line 8) / sys = ss(A, B, C, D); ???

4 vues (au cours des 30 derniers jours)
meoui
meoui le 25 Sep 2024
Commenté : Sam Chak le 25 Sep 2024
% 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 commentaires
Aquatris
Aquatris le 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.
Sam Chak
Sam Chak le 25 Sep 2024
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.

Connectez-vous pour commenter.

Réponses (1)

Sandeep Mishra
Sandeep Mishra le 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

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by