Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
66 views2 pages

Structural Analysis with MATLAB

The document contains code for a finite element analysis of a two bar truss structure. It defines material properties, geometry, applies loads and boundary conditions. It then assembles the global stiffness matrix and force vector, solves for displacements, and post-processes for internal forces and stresses.

Uploaded by

jeff scylla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views2 pages

Structural Analysis with MATLAB

The document contains code for a finite element analysis of a two bar truss structure. It defines material properties, geometry, applies loads and boundary conditions. It then assembles the global stiffness matrix and force vector, solves for displacements, and post-processes for internal forces and stresses.

Uploaded by

jeff scylla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

clc;

clear;

%Input
E = 1;
A = 1;
L1 = sqrt(5^2+(3.2^2));
L2 = sqrt(3^2+2^2);
P = 8;
q=0

%Solution

k1 = A*E* [1/(L1) -1/(L1);


-1/(L1) 1/(L1)];
k2 = A*E* [1/(L2) -1/(L2);
-1/(L2) 1/(L2)];
c1 = cos (-3/5);
s1 = sin (-3/5);
T1 = [c1 s1 0 0;
0 0 c1 s1];
c2 = cos (3/2);
s2 = sin (3/2);
T2 = [c2 s2 0 0;
0 0 c2 s2];

r1 = [q*L1/2 q*L1/2];
r2 = [q*L2/2 q*L2/2];

klocal1 = T1'*k1*T1
klocal2 = T2'*k2*T2
%Assemble global matrix
K = zeros(6);
K(1:4, 1:4) = K(1:4, 1:4) + klocal1;
K(3:6, 3:6) = K(3:6, 3:6) + klocal2;
Kglobal = K
R = zeros(6,1);
Rglobal = R

%Point load,P at end of bar


R(4) = R(4) + (-P);
%Boundary conditions
K (:,1) = 0;
K (1,:) = 0;
K (1,1) = 1;
R(1) = 0;
K (:,2) = 0;
K (2,:) = 0;
K (2,2) = 1;
R(2) = 0;
K (:,5) = 0;
K (5,:) = 0;
K (5,5) = 1;
R(5) = 0;
K (:,6) = 0;
K (6,:) = 0;
K (6,6) = 1;
R(6) = 0;
K
%Solve global displacement
U = K \ R

%FEM solution
%Internal force, stress or reaction
b = (Kglobal*U) - Rglobal

U1 = T1*U(1:4)
B1 = k1*U1
S1 = B1/A
U2 = T2*U(3:6)
B2 = k2*U2
S2 = B2/A

You might also like