Answered step by step
Verified Expert Solution
Question
1 Approved Answer
What is wrong with my matlab code?Problem 2 . 7 P = 7 . 1 0 ^ 3 ; % Applied load in N E
What is wrong with my matlab code?Problem
P ; Applied load in N
E ; Young's modulus in Pa
A ; Crosssectional area in m
L ; Length of each square in m
W ; Width of the rectangle in m
Define node coordinates
nodes ; L ; L ; L ; L ; L; L L; L L; L L; L L;
Define element connectivity
elements ; ; ; ; ; ; ; ; ; ; ; ; ;
numNodes sizenodes;
numElements sizeelements;
K zerosnumNodes;
F zerosnumNodes;
for i :numElements
node elementsi;
node elementsi;
x nodesnode;
y nodesnode;
x nodesnode;
y nodesnode;
L normx x y y;
cosTheta x x L;
sinTheta y y L;
k E A LcosTheta cosThetasinTheta; cosThetasinTheta sinTheta;
Assemble into global stiffness matrix
index nodenodenodenode;
Kindex index Kindex index k;
Apply nodal loads
Fnode Fnode P cosTheta;
Fnode Fnode P sinTheta;
end
penalty e; Adjust this value as needed
fixedNode ; Assuming the first node is fixed
KfixedNode :) ;
K: fixedNode;
KfixedNode fixedNode penalty;
KfixedNode :) ;
K: fixedNode;
KfixedNode fixedNode penalty;
FfixedNode;
FfixedNode;
U K F;
stresses zerosnumElements;
for i :numElements
node elementsi;
node elementsi;
x nodesnode;
y nodesnode;
x nodesnode;
y nodesnode;
L normx x y y;
cosTheta x x L;
sinTheta y y L;
strain cosTheta sinThetaUnode; UnodecosTheta sinThetaUnode; Unode L;
stressesi E strain;
end
mag ; Magnification factor for better visualization
defNodes nodes mag reshapeU;
figure;
hold on;
for i :numElements
node elementsi;
node elementsi;
plotnodesnode nodesnodenodesnode nodesnodeb 'LineWidth', ;
end
for i :sizedefNodes
plotdefNodesi defNodesiro 'MarkerSize', ;
end
xlabelx m;
ylabely m;
titleDeformed Structure';
axis equal;
grid on;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started