Taking error message in matlab

1 view (last 30 days)
Ahmet Akcura
Ahmet Akcura on 21 Jun 2022
Commented: Ahmet Akcura on 21 Jun 2022
In the below, we have our matlab code but we are taking error and error massage is;
Error using ss (line 355)
The "A" and "B" matrices must have the same number of rows.
Error in lateral (line 34)
MSS = ss(A_lat,B_lat,C_lat,D_lat)
What should we do? If you have any suggestion for us, we will be very happy.
The code is ;
%parameters
Mach = 0.206;
U_zero = 70;
q_dot = 2997;
alpha_zero = 11.7;
gamma_zero = 0;
g = 9.81;
%lateral values
Y_b = -21.1;
L_dotb = -10.4;
L_dotp = -1.43;
L_dotr = 0.929;
N_dotb = 1.44;
N_dotp = -0.026;
N_dotr = -0.215;
Y_starsa = -0.004;
Y_starsr = 0.0053;
L_dotsa = 2.74;
L_dotsr = 0.7;
N_dotsa = 0.42;
N_dotsr = -0.67;
A_lat = [Y_b 0 -1 g/U_zero 0; L_dotb L_dotp L_dotr 0 0; N_dotb N_dotp N_dotr 0 0; 0 1 0 0 0; 0 0 1 0 0];
B_lat = [0 Y_starsr; L_dotsa L_dotsr; N_dotsa N_dotsr ; 0 0];
C_lat = [1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1];
D_lat = [0; 0; 0; 0];
I = eye(4,4);
figure(3)
MSS = ss(A_lat,B_lat,C_lat,D_lat)
Transfer=tf(MSS)
step(MSS,3000)
grid on
  4 Comments
Torsten
Torsten on 21 Jun 2022
Edited: Torsten on 21 Jun 2022
Take away one row in A :-)
In the documentation of ss, the sizes of the input matrices to be compatible are listed:
Edward Tomanek
Edward Tomanek on 21 Jun 2022
I know what you mean, but all MATLAB is telling you is that all those matrices need to have the same number of rows for the function to work. I don't know the specifics of the example at hand but if matrix A_lat ends up having more rows there may be some way to convert it to having a lower number of rows?

Sign in to comment.

Answers (1)

Edward Tomanek
Edward Tomanek on 21 Jun 2022
Hi,
In the line:
MSS = ss(A_lat,B_lat,C_lat,D_lat)
You are using the state-space model, documentation found here https://uk.mathworks.com/help/control/ref/ss.html
Your error message is telling you that all the matrices need to have the same number of rows for this function to work. For example, using
A = [1, 2; 3, 4; 5, 6]
B = [2, 3; 4, 5]
would not work because A has 3 rows and B only has 2 (i.e. all the matrices need to have the same numbers of semi-colons).
Notice that in your definitions, B_lat, C_lat and D_lat all have 4 rows but A_lat has 5. That is what's causing the error.
Regards,
Edward
  3 Comments
Steven Lord
Steven Lord on 21 Jun 2022
If A has 5 rows and B has 4 rows, the values A*x and B*u must have 5 and 4 rows respectively. Adding together matrices with different numbers of rows is not mathematically defined. I would double check that I'd copied the A_lat, B_lat, etc. matrices correctly from whatever paper / book / etc. I was trying to implement.
Ahmet Akcura
Ahmet Akcura on 21 Jun 2022
Thank you so much for your effort, I found my mistake :)

Sign in to comment.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!