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

조회 수: 7 (최근 30일)
meoui
meoui 2024년 9월 25일
댓글: Sam Chak 2024년 9월 25일
% 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
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
Sam Chak 2024년 9월 25일
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
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

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by