help on error message
显示 更早的评论
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,
采纳的回答
更多回答(2 个)
Image Analyst
2020-4-17
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!