Answered step by step
Verified Expert Solution
Link Copied!

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 2.7
P =7.10^3; % Applied load in N
E =1.5*10^11; % Young's modulus in Pa
A =10^(-2); % Cross-sectional area in m^2
L =3; % Length of each square in m
W =4; % Width of the rectangle in m
% Define node coordinates
nodes =[00; L 0; 2*L 0; 3*L 0; 4*L 0; 0 L; L L; 2*L L; 3*L L; 4*L L];
% Define element connectivity
elements =[12; 23; 34; 45; 16; 27; 38; 49; 510; 67; 78; 89; 910];
numNodes = size(nodes,1);
numElements = size(elements,1);
K = zeros(2*numNodes);
F = zeros(2*numNodes,1);
for i =1:numElements
node1= elements(i,1);
node2= elements(i,2);
x1= nodes(node1,1);
y1= nodes(node1,2);
x2= nodes(node2,1);
y2= nodes(node2,2);
L = norm([x2- x1, y2- y1]);
cosTheta =(x2- x1)/ L;
sinTheta =(y2- y1)/ L;
k =(E A / L)[cosTheta^2 cosTheta*sinTheta; cosTheta*sinTheta sinTheta^2];
% Assemble into global stiffness matrix
index =[2*node1-1,2*node1,2*node2-1,2*node2];
K(index, index)= K(index, index)+ k;
% Apply nodal loads
F(2*node2-1)= F(2*node2-1)+ P * cosTheta;
F(2*node2)= F(2*node2)+ P * sinTheta;
end
penalty =1e9; % Adjust this value as needed
fixedNode =1; % Assuming the first node is fixed
K(fixedNode*2-1, :) =0;
K(:, fixedNode*2-1)=0;
K(fixedNode*2-1, fixedNode*2-1)= penalty;
K(fixedNode*2, :) =0;
K(:, fixedNode*2)=0;
K(fixedNode*2, fixedNode*2)= penalty;
F(fixedNode*2-1)=0;
F(fixedNode*2)=0;
U = K \ F;
stresses = zeros(numElements,1);
for i =1:numElements
node1= elements(i,1);
node2= elements(i,2);
x1= nodes(node1,1);
y1= nodes(node1,2);
x2= nodes(node2,1);
y2= nodes(node2,2);
L = norm([x2- x1, y2- y1]);
cosTheta =(x2- x1)/ L;
sinTheta =(y2- y1)/ L;
strain =([cosTheta sinTheta][U(2node2-1); U(2*node2)]-[cosTheta sinTheta][U(2node1-1); U(2*node1)])/ L;
stresses(i)= E * strain;
end
mag =1000; % Magnification factor for better visualization
defNodes = nodes + mag * reshape(U,[],2);
figure;
hold on;
for i =1:numElements
node1= elements(i,1);
node2= elements(i,2);
plot([nodes(node1,1), nodes(node2,1)],[nodes(node1,2), nodes(node2,2)],'b-', 'LineWidth', 1);
end
for i =1:size(defNodes,1)
plot(defNodes(i,1), defNodes(i,2),'ro', 'MarkerSize', 5);
end
xlabel('x (m)');
ylabel('y (m)');
title('Deformed Structure');
axis equal;
grid on;
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 3 Lnai 8726

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448440, 978-3662448441

More Books

Students also viewed these Databases questions

Question

Who was the first woman prime minister of india?

Answered: 1 week ago

Question

Explain the concept of going concern value in detail.

Answered: 1 week ago

Question

Define marketing.

Answered: 1 week ago

Question

What are the traditional marketing concepts? Explain.

Answered: 1 week ago

Question

5. Describe the visual representations, or models, of communication

Answered: 1 week ago