Matrix dimensions must agree. error .
1 view (last 30 days)
Show older comments
%***** CALCULATE STRESS *****
stress1 = ones(1,6);
stress2 = ones(1,6);
direct = ones(1,6);
for i = 1:n_elem
lambda = [l_ij(i) m_ij(i) 0 0 0 0 ;...
-m_ij(i) l_ij(i) 0 0 0 0 ;...
0 0 1 0 0 0 ;...
0 0 0 l_ij(i) m_ij(i) 0 ;...
0 0 0 -m_ij(i) l_ij(i) 0 ;...
0 0 0 0 0 1];
B1Direct = [-1/l(i) 0 0 1/l(i) 0 0];
B1 = [-1/l(i) 6*t/l(i)^2 4*t/l(i) 1/l(i) (-6)*(t)/l(i)^2 (t)*(2)/l(i)];
B2 = [-1/l(i) -6*t/l(i)^2 -2*t/l(i) ...
1/l(i) 6*t/l(i)^2 -4*t/l(i)];
q = [u(connect(i,1)*3 - 2);...
u(connect(i,1)*3 - 1);
u(connect(i,1)*3);...
u(connect(i,2)*3 - 2);...
u(connect(i,2)*3 - 1);...
u(connect(i,2)*3)];
stress1(i) = (E(i)* B1) .* lambda .* q ;
stress2(i) = (E(i) * B2) .* lambda .* q ;
direct(i) = (E(i) * B1Direct) .* lambda .* q ;
end
%%Displays results as table format for the stresses node i of element
di = cell(1,n_elem); %Node in x Direction
for i=1:n_elem % Defines the number of the node
di{i} = ['elem' num2str(i)];
end
dirc = (reshape((di), size(di,1), (di))).'; %Concatenates node
stress_i_nodeMPa=table(dirc,round(stress1',4)); % Defines the values to show in table
stress_i_nodeMPa.Properties.VariableNames = {'Element','Stress'}; %Table column names
%%Displays results as table format for the stresses node j of element
sj = cell(1,n_elem); %Node in x Direction
for i=1:n_elem % Defines the number of the node
sj{i} = ['elem' num2str(i)];
end
stjc = (reshape((sj), size(sj,1), [])).'; %Concatenates node
stress_j_nodeMPa=table(stjc,round(stress2',4)); % Defines the values to show in table
stress_j_nodeMPa.Properties.VariableNames = {'Element','Stress'}; %Table column names
%%Displays results as table format for the direct stresses
di = cell(1,n_elem); %Node in x Direction
for i=1:n_elem % Defines the number of the node
di{i} = ['elem' num2str(i)];
end
dirc = (reshape((di), size(di,1), [])).'; %Concatenates node
DirStressMPa=table(dirc,round(direct',4)); % Defines the values to show in table
DirStressMPa.Properties.VariableNames = {'Element','Stress'}; %Table column names
Answers (0)
See Also
Categories
Find more on Stress and Strain in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!