i keep receiving this error message in matlab
I keep receiving this error message in matlab. im trying to write a script for a plane trust problem for school dont know what im doing wrong at this point. any help is welcome. error message "Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns
in the first matrix matches the number of rows in the second matrix. To operate on
each element of the matrix individually, use TIMES (.*) for elementwise
multiplication.
Error in untitled17 (line 78)
k_Aeg=T_x’*k_ee*T_x+T_y’*k_ee*T_y;
% Constants
i = 1; % length of horizontal and vertical members
sqrt2i = sqrt(2) * i; % length of inclined members
E = 100e9; % Young’s modulus (Pa)
A = 1e-4; % cross-sectional area (m^2)
i = 0.3; % moment of inertia (m)
% Define external loads
Fx13 = 10000;
Fx14 = 10000;
Fy13 = 0;
Fy14 = 0;
% Load Case A: Fx13 = Fx14 = 10,000 N
FxA = [10000; 0];
FyA = [0; -10000];
% Load Case B: Fy13 = Fy14 = 10,000 N
FxB = [0; -10000];
FyB= [-10000; 0];
% Load Case C: Fx13=10,000 N and Fx14=-10,000 N
FxC= [10000;-10000];
FyC= [-20000;-20000];
% Assemble global stiffness matrix K and global force vector P for each load case
% Initialize matrices/vectors with zeros
K_A=zeros(6);
P_A=zeros(6,1);
K_B=zeros(6);
P_B=zeros(6,1);
K_C=zeros(6);
P_C=zeros(6,1);
% Define local element stiffness matrix k_e and local force vector p_e
k_e=A*E/i*[1 -1;-1 1]
p_e=[sqrt2i/2;i/2]*[Fx13,Fy13]
for e=[3] %(number of elements)
k_ee=k_e;
p_ee=p_e;
if(e==3)%horizontal member
T_x =[1 0 0 -1];
T_y=[0 1 -1 0];
end
if(e==4)%vertical member
T_x =[0 -1 1 0];
T_y=[-1/2 sqrt2i/2 sqrt2i/2 -1/2];
end
% Compute global element stiffness matrix K_e and global element force vector P_e
K_Ae = zeros(6);
p_Ae = zeros(6, 1);
K_Be = zeros(6);
p_Be = zeros(6, 1);
K_Ce = zeros(6);
p_Ce = zeros(6, 1);
size(T_x’)
size(k_ee)
size(T_x)
size(T_y’)
size(k_ee)
size(T_y)
% Transform local stiffness matrix to global coordinates
k_Aeg=T_x’*k_ee*T_x+T_y’*k_ee*T_y;
p_Aeg=T_x’*p_ee;
% Add element contributions to the global stiffness matrix and force vector
K_A([3:4],[3:4])=K([3:4],[3:4])+k_Aeg;
P_A([3:4])=P([3:4])+p_Peg;
end
% Solve for displacements using KU=P equation
U_A=KPI keep receiving this error message in matlab. im trying to write a script for a plane trust problem for school dont know what im doing wrong at this point. any help is welcome. error message "Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns
in the first matrix matches the number of rows in the second matrix. To operate on
each element of the matrix individually, use TIMES (.*) for elementwise
multiplication.
Error in untitled17 (line 78)
k_Aeg=T_x’*k_ee*T_x+T_y’*k_ee*T_y;
% Constants
i = 1; % length of horizontal and vertical members
sqrt2i = sqrt(2) * i; % length of inclined members
E = 100e9; % Young’s modulus (Pa)
A = 1e-4; % cross-sectional area (m^2)
i = 0.3; % moment of inertia (m)
% Define external loads
Fx13 = 10000;
Fx14 = 10000;
Fy13 = 0;
Fy14 = 0;
% Load Case A: Fx13 = Fx14 = 10,000 N
FxA = [10000; 0];
FyA = [0; -10000];
% Load Case B: Fy13 = Fy14 = 10,000 N
FxB = [0; -10000];
FyB= [-10000; 0];
% Load Case C: Fx13=10,000 N and Fx14=-10,000 N
FxC= [10000;-10000];
FyC= [-20000;-20000];
% Assemble global stiffness matrix K and global force vector P for each load case
% Initialize matrices/vectors with zeros
K_A=zeros(6);
P_A=zeros(6,1);
K_B=zeros(6);
P_B=zeros(6,1);
K_C=zeros(6);
P_C=zeros(6,1);
% Define local element stiffness matrix k_e and local force vector p_e
k_e=A*E/i*[1 -1;-1 1]
p_e=[sqrt2i/2;i/2]*[Fx13,Fy13]
for e=[3] %(number of elements)
k_ee=k_e;
p_ee=p_e;
if(e==3)%horizontal member
T_x =[1 0 0 -1];
T_y=[0 1 -1 0];
end
if(e==4)%vertical member
T_x =[0 -1 1 0];
T_y=[-1/2 sqrt2i/2 sqrt2i/2 -1/2];
end
% Compute global element stiffness matrix K_e and global element force vector P_e
K_Ae = zeros(6);
p_Ae = zeros(6, 1);
K_Be = zeros(6);
p_Be = zeros(6, 1);
K_Ce = zeros(6);
p_Ce = zeros(6, 1);
size(T_x’)
size(k_ee)
size(T_x)
size(T_y’)
size(k_ee)
size(T_y)
% Transform local stiffness matrix to global coordinates
k_Aeg=T_x’*k_ee*T_x+T_y’*k_ee*T_y;
p_Aeg=T_x’*p_ee;
% Add element contributions to the global stiffness matrix and force vector
K_A([3:4],[3:4])=K([3:4],[3:4])+k_Aeg;
P_A([3:4])=P([3:4])+p_Peg;
end
% Solve for displacements using KU=P equation
U_A=KP I keep receiving this error message in matlab. im trying to write a script for a plane trust problem for school dont know what im doing wrong at this point. any help is welcome. error message "Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns
in the first matrix matches the number of rows in the second matrix. To operate on
each element of the matrix individually, use TIMES (.*) for elementwise
multiplication.
Error in untitled17 (line 78)
k_Aeg=T_x’*k_ee*T_x+T_y’*k_ee*T_y;
% Constants
i = 1; % length of horizontal and vertical members
sqrt2i = sqrt(2) * i; % length of inclined members
E = 100e9; % Young’s modulus (Pa)
A = 1e-4; % cross-sectional area (m^2)
i = 0.3; % moment of inertia (m)
% Define external loads
Fx13 = 10000;
Fx14 = 10000;
Fy13 = 0;
Fy14 = 0;
% Load Case A: Fx13 = Fx14 = 10,000 N
FxA = [10000; 0];
FyA = [0; -10000];
% Load Case B: Fy13 = Fy14 = 10,000 N
FxB = [0; -10000];
FyB= [-10000; 0];
% Load Case C: Fx13=10,000 N and Fx14=-10,000 N
FxC= [10000;-10000];
FyC= [-20000;-20000];
% Assemble global stiffness matrix K and global force vector P for each load case
% Initialize matrices/vectors with zeros
K_A=zeros(6);
P_A=zeros(6,1);
K_B=zeros(6);
P_B=zeros(6,1);
K_C=zeros(6);
P_C=zeros(6,1);
% Define local element stiffness matrix k_e and local force vector p_e
k_e=A*E/i*[1 -1;-1 1]
p_e=[sqrt2i/2;i/2]*[Fx13,Fy13]
for e=[3] %(number of elements)
k_ee=k_e;
p_ee=p_e;
if(e==3)%horizontal member
T_x =[1 0 0 -1];
T_y=[0 1 -1 0];
end
if(e==4)%vertical member
T_x =[0 -1 1 0];
T_y=[-1/2 sqrt2i/2 sqrt2i/2 -1/2];
end
% Compute global element stiffness matrix K_e and global element force vector P_e
K_Ae = zeros(6);
p_Ae = zeros(6, 1);
K_Be = zeros(6);
p_Be = zeros(6, 1);
K_Ce = zeros(6);
p_Ce = zeros(6, 1);
size(T_x’)
size(k_ee)
size(T_x)
size(T_y’)
size(k_ee)
size(T_y)
% Transform local stiffness matrix to global coordinates
k_Aeg=T_x’*k_ee*T_x+T_y’*k_ee*T_y;
p_Aeg=T_x’*p_ee;
% Add element contributions to the global stiffness matrix and force vector
K_A([3:4],[3:4])=K([3:4],[3:4])+k_Aeg;
P_A([3:4])=P([3:4])+p_Peg;
end
% Solve for displacements using KU=P equation
U_A=KP 2-d plane truss MATLAB Answers — New Questions