
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

%MATLAB script to solve the three truss elements problem % Element number Nelem = 3; % Cross-sectional area b = [1. 1.2 1.4]; % Length of each element l = [0.5 0.75 1.0]; % Young's modulus E = 1E4; % Global stiffness matrix K = zeros(4,4); % Assemble the stiffness matrix for i = 1:Nelem coef = E*b(i)/l(i); K(i,i) = K(i,i) + coef; K(i,i+1) = K(i,i+1) - coef; K(i+1,i) = K(i+1,i) - coef; K(i+1,i+1) = K(i+1,i+1) + coef; end % Applied force vector F = [ 0 0 0 10]'; % Apply displacement boundary condition at node 1 for i = 1:Nelem+ K(1,i) = 0; end K(1,1) = 1; % Solve the problem for displacement z z = K \ F % Calculate stress sigma = zeros(3,1); for i = 1:Nelem coef = E/l(i); sigma(i) = coef * (z(i+1) - z(i)); end sigma