Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Error in first line, looks fine though

1 visualización (últimos 30 días)
Jeremy Carlisle
Jeremy Carlisle el 1 de Jun. de 2020
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I'm trying to obtain the commented out varibales (matrix B) but I get an error in the first line
"Error in example_112 (line 1)
A = [ 1 0 1 0 0 0 ; 0 1 0 1 0 0 ; -r122 r121 -r322 r321 0 1 ; 0 0 -1 0 1 0 ; 0 0 0 -1 u 0 ; 0 0 r232 -r231
(u*r131-r132) 0 ]; "
I'm not sure if it has something to do with the second last variable but it doesn't want to run.
A = [ 1 0 1 0 0 0 ; 0 1 0 1 0 0 ; -r122 r121 -r322 r321 0 1 ; 0 0 -1 0 1 0 ; 0 0 0 -1 u 0 ; 0 0 r232 -r231 (u*r131-r132) 0 ];
%[B = [ f121 ; f122 ; f321 ; f322 ; f131 ; T12];
C = [ m2*ag21 ; m2*ag22 ; ig2*aa2 ; m3*ag31 -fp1 ; m3*ag32 -fp2 ; ig3*aa3 -rp1*fp2 +rp2*fp1 ];
r12 = 3;
r32 = 2.83;
r23 = 9;
r13 = 10.72;
rp = 2.7;
r121 = r12*cosd(270);
r122 = r12*sind(270);
r322 = r32*cosd(28);
r321 = r32*sind(28);
r231 = r23*cosd(324.5);
r232 = r23*sind(324.5);
r131 = r13*cosd(63.14);
r132 = r13*sind(63.14);
rp1 = rp*cosd(201);
rp2 = rp*sind(201);
fp = 50;
%{
f121 ;
f122 ;
f321 ;
f322 ;
f131 ;
%}
fp1 = fp*cosd(-45);
fp2 = fp*sind(-45);
ag2 = 2700.17;
ag3 = 3453.35;
ag21 = ag2*cosd(-89.4);
ag22 = ag2*sind(-89.4);
ag31 = ag3*cosd(254.4);
ag32 = ag3*sind(254.4);
aa2 = -10;
aa3 = -136.16;
ig3 = 0.1;
u = 0.2;
m2 = 2/386;
m3 = 4/386;
%[ T12 ;
Y = inv(a);
B = Y*C;
  1 comentario
Mohammad Sami
Mohammad Sami el 1 de Jun. de 2020
Your code only defines the values for rXXX and u after you have tried to use them to create matrix A.
Your matrix A definition require the variable rXXX and u to be defined first.

Respuestas (1)

Dinesh Yadav
Dinesh Yadav el 3 de Jun. de 2020
On top of what Mohammad Sami said, after moving the matrix A and B just above second last line of your code so all variable definitions are available for your matrices, still definition of ig2 variable is missing in matrix C. Kindly check again that you have defined all the variable you need before you use them. Second there are spaces in matrix C such as 'm3*ag31 -fp1' these will be treated as 2 different entities (i.e 2 columns) and you will again get error related to dimensions not being consistent. After removing unnecessary spaces, the third error will be due to "Y=inv(a)" as it should be "Y=inv(A)". After that the code runs without error.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by