help on error message
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Daniel Mehari
el 17 de Abr. de 2020
Respondida: Daniel Mehari
el 18 de Abr. de 2020
am getting error that says
Error using horzcat
Dimensions of arrays being concatenated are not
consistent.
Error in Plot2DBarBeam (line 364)
disp([(1:EL)' out.M1/1E3]);
Error in A1_general (line 38)
Plot2DBarBeam(inp,out,plt,file);
the code reffered as wrong is as far as i understand is :
% Axial forces
Nx = @(EA,L,u1,u2) (EA/L)*(u2-u1); % function for the axial force
Mz= @ (E,I,Le,x,v1,d1,v2,d2) E*I*((-6/Le^2+12*x/Le^3)*v1+(-4/Le+6*x/Le^2)...
*d1+(6/Le^2-12*x/Le^3)*v2+(-2/Le+6*x/Le^2)*d2);
for i=1:EL
% transformation matrix
d_prim = T*D(edof(i,:)); % local displacements, EL_i
N(i) = Nx(E*A,Le(i),d_prim(1),d_prim(4));
M1(i)=Mz(E,I,Le(i),0,d_prim(2),d_prim(3),d_prim(5),d_prim(6));
M2(i)=Mz(E,I,Le(i),Le(i),d_prim(2),d_prim(3),d_prim(5),d_prim(6));
V(i)=E*I*((12/Le(i)^3)*d_prim(2)+(6/Le(i)^2)*d_prim(3)+(-12/Le(i)^3)*d_prim(5)+(6/Le(i)^2)*d_prim(6)) ;
I can not understand what the error implies, would like to have some hints to solve this error?
Thanks,
0 comentarios
Respuesta aceptada
Geoff Hayes
el 17 de Abr. de 2020
Daniel - in the line of code
disp([(1:EL)' out.M1/1E3]);
you are horizontally concatenating the column (because of the transpose) array (1:EL)' with whatever out.M1/1E3 is. If both of these parameters don't have the same number of rows, then you will observe this error. What are the dimensions of the second parameter?
2 comentarios
Más respuestas (2)
Image Analyst
el 17 de Abr. de 2020
See if this explains it:
% Define 1-D row vectors and 2-D matrix.
v1 = [1,2,3] % One row vector.
v2 = [4,5,6] % Another one-row vector.
m = [1,2,3; 7,8,9] % A two-row matrix.
% Now try to horizontally concatenate them.
% These lines will work:
v12a = horzcat(v1, v2) % This will work because both have one row.
v12b = [v1, v2] % This will work because both have one row.
% Neither of these will work because you can't have different number of rows in each column.
% In other words you can't have
% 1 2 3 1 2 3
% 7 8 9
% Because columns 1-3 have only 1 row while columns 4-6 would have two rows.
badMatrix = horzcat(v1, m) % Throws error
badMatrix = [v1, m] % Throws error
% Running either of those two lines would throw this error:
% Error using horzcat
% Dimensions of arrays being concatenated are not consistent.
You'll see
v1 =
1 2 3
v2 =
4 5 6
m =
1 2 3
7 8 9
v12a =
1 2 3 4 5 6
v12b =
1 2 3 4 5 6
Then, at the next line, when you try to horizontally concatenate a matrix onto a row vector, you'll see:
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
1 comentario
Image Analyst
el 17 de Abr. de 2020
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!