Title: Truss Example
1Truss Example
Solving Linear Systems with Matlab
2Find the axial forces in each of the members of
this truss
Problem
Ax
Ay1
Ay2
100
3the ASCII files
Ex1StructPoints.dat
Ex1StructConnect.dat
joint x-coord y-coord 1 0 0 2
0.5 0 3 1 0 4 1.5
0 5 2 0 6 0.5 0.5 7
1.5 0.5 8 1 1
member joint1 joint2 1 1 6 2
1 2 3 2 6 4 6 8
5 3 6 6 2 3 7 3
8 8 7 8 9 3 7 10
3 4 11 4 7 12 5
7 13 4 5
4Skills needed to solve this problem
5Understanding the linear system
Joint 8
å F F4 F7 F8 0
å Fx F4,x F7,x F8,x 0
å Fy F4,y F7,y F8,y 0
F4
F8
F7
6Understanding the linear system
The Unit Vector
F
e
F
Fx
ex
F
Fy
ey
F
7Understanding the linear system
Joint 8
å F F4 F7 F8 0
å Fx e4,x F4 e7,x F7 e8,x F8 0
å Fy e4,y F4 e7,y F7 e8,y F8 0
F4
F8
F7
8Understanding the linear system
-Ax 0 0 0 0 0 0 0 -Ay1 0 100 0 -Ay2 0 0 0
0 0 0 ex,4-5 ex,5-4 0 0 0 0 0 0 ey,4-5 ey,5-4 0 0
0
ex,1-2 ex,2-1 0 0 0 0 0 0 ey,1-2 ey,2-1 0 0 0 0 0
0
ex,1-6 0 0 0 0 ex,6-1 0 0 ey,1-6 0 0 0 0 ey,6-1 0
0
0 ex,2-6 0 0 0 ex,6-2 0 0 0 ey,2-6 0 0 0 ey,6-2 0
0
0 0 0 0 0 ex,6-8 0 ex,8-6 0 0 0 0 0 ey,6-8 0 ey,8-
6
0 0 ex,3-6 0 0 ex,6-3 0 0 0 0 ey,3-6 0 0 ey,6-3 0
0
0 ex,2-3 ex,3-2 0 0 0 0 0 0 ey,2-3 ey,3-2 0 0 0 0
0
0 0 ex,3-8 0 0 0 0 ex,8-3 0 0 ey,3-8 0 0 0 0 ey,8-
3
0 0 0 0 0 0 ex,7-8 ex,8-7 0 0 0 0 0 0 ey,7-8 ey,8-
7
0 0 ex,3-7 0 0 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F13
10Understanding the linear system
F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13
0 0 0 0 0 0 0 0 100 0 0 0 0
0 0 ex,4-5 ex,5-4 0 0 0 0 0 ey,4-5 0 0 0
ex,2-1 0 0 0 0 0 0 ey,2-1 0 0 0 0 0
0 0 0 0 ex,6-1 0 0 0 0 0 ey,6-1 0 0
ex,2-6 0 0 0 ex,6-2 0 0 ey,2-6 0 0 ey,6-2 0 0
0 0 0 0 ex,6-8 0 ex,8-6 0 0 0 ey,6-8 0 ey,8-6
0 ex,3-6 0 0 ex,6-3 0 0 0 ey,3-6 0 ey,6-3 0 0
ex,2-3 ex,3-2 0 0 0 0 0 ey,2-3 ey,3-2 0 0 0 0
0 ex,3-8 0 0 0 0 ex,8-3 0 ey,3-8 0 0 0 ey,8-3
0 0 0 0 0 ex,7-8 ex,8-7 0 0 0 0 ey,7-8 ey,8-7
0 ex,3-7 0 0 0 ex,7-3 0 0 ey,3-7 0 0 ey,7-3 0
0 ex,3-4 ex,4-3 0 0 0 0 0 ey,3-4 ey,4-3 0 0 0
0 0 ex,4-7 0 0 ex,7-4 0 0 0 ey,4-7 0 ey,7-4 0
0 0 0 ex,5-7 0 ex,7-5 0 0 0 0 0 ey,7-5 0
11Programming the solution
Problem Solving Outline
Extract data from ASCII files
Find unit vector components
Compile all equilibrium equations from all joints
Eliminate unnecessary equations
Solve equations by Gaussian elimination
12Programming the solution
Extract data from ASCII files
Ex1StructPoints.dat
Ex1StructConnect.dat
joint x-coord y-coord 1 0 0 2
0.5 0 3 1 0 4 1.5
0 5 2 0 6 0.5 0.5 7
1.5 0.5 8 1 1
member joint1 joint2 1 1 6 2
1 2 3 2 6 4 6 8
5 3 6 6 2 3 7 3
8 8 7 8 9 3 7 10
3 4 11 4 7 12 5
7 13 4 5
13Programming the solution
Extract data from ASCII files
Ex1StructPoints.dat
Ex1StructPointsMod.dat
joint x-coord y-coord 1 0 0 2
0.5 0 3 1 0 4 1.5
0 5 2 0 6 0.5 0.5 7
1.5 0.5 8 1 1
1 0 0 2 0.5 0 3 1
0 4 1.5 0 5 2 0 6
0.5 0.5 7 1.5 0.5 8 1
1
14Programming the solution
Extract data from ASCII files
Ex1StructConnect.dat
Ex1StructConnectMod.dat
member joint1 joint2 1 1 6 2
1 2 3 2 6 4 6 8
5 3 6 6 2 3 7 3
8 8 7 8 9 3 7 10
3 4 11 4 7 12 5
7 13 4 5
1 1 6 2 1 2 3 2
6 4 6 8 5 3 6 6
2 3 7 3 8 8 7
8 9 3 7 10 3 4 11
4 7 12 5 7 13 4 5
15Programming the solution
Extract data from ASCII files
load Ex1StructJointsMod.dat load
Ex1StructConnectMod.dat Matrix with
coordinates of joints coord Ex1StructJointsMod(
,23) Connectivity matrix C
Ex1StructConnectMod(,23)
16Programming the solution
Extract data from ASCII files
load Ex1StructJointsMod.dat load
Ex1StructConnectMod.dat Matrix with
coordinates of joints coord Ex1StructJointsMod(
,23) Connectivity matrix C
Ex1StructConnectMod(,23)
17Programming the solution
Find unit vector components
num_joints size(Ex2StructJointsMod,1)
Distance matrix i X j for i
1num_joints for j 1num_joints
dist(i,j) ((coord(i,1)-coord(j,1))2
(coord(i,2)-coord(j,2))2)(1/2)
end end
18Programming the solution
Find unit vector components
Unit vector matrices (x-component and
y-component) iXj for i 1num_joints
for j 1num_joints if (dist(i,j) 0)
x_comp(i,j) 0 y_comp(i,j) 0
else x_comp(i,j)
(coord(j,1)-coord(i,1))/dist(i,j)
y_comp(i,j) (coord(j,2)-coord(i,2))/dist(i,j)
end end end
19Programming the solution
Compile all equilibrium equations from all joints
num_members size(Ex1StructConnectMod,1)
Matrix construction for linear system for m
1num_members Mat( C(m,1) , m) x_comp(
C(m,1) , C(m,2) ) Mat( C(m,2) , m)
x_comp( C(m,2) , C(m,1) ) Mat(
C(m,1)num_joints, m) y_comp( C(m,1) , C(m,2)
) Mat( C(m,2)num_joints, m) y_comp( C(m,2)
, C(m,1) ) end Equilibrium constant for net
force at each joint eq_const zeros(2num_joints,
1) eq_const(num_joints2)100
20Programming the solution
Compile all equilibrium equations from all joints
num_members size(Ex1StructConnectMod,1)
Matrix construction for linear system for m
1num_members Mat( C(m,1) , m) x_comp(
C(m,1) , C(m,2) ) Mat( C(m,2) , m)
x_comp( C(m,2) , C(m,1) ) Mat(
C(m,1)num_joints, m) y_comp( C(m,1) , C(m,2)
) Mat( C(m,2)num_joints, m) y_comp( C(m,2)
, C(m,1) ) end Equilibrium constant for net
force at each joint eq_const zeros(2num_joints,
1) eq_const(num_joints2)100
21Programming the solution
Compile all equilibrium equations from all joints
num_members size(Ex1StructConnectMod,1)
Matrix construction for linear system for m
1num_members Mat( C(m,1) , m) x_comp(
C(m,1) , C(m,2) ) Mat( C(m,2) , m)
x_comp( C(m,2) , C(m,1) ) Mat(
C(m,1)num_joints, m) y_comp( C(m,1) , C(m,2)
) Mat( C(m,2)num_joints, m) y_comp( C(m,2)
, C(m,1) ) end Equilibrium constant for net
force at each joint eq_const zeros(2num_joints,
1) eq_const(num_joints3)100
22Programming the solution
Eliminate unnecessary equations
Elimination of unnecessary equations
rows 210, 12, 1420 AA Mat( rows
, ) rhs eq_const( rows , )
23Programming the solution
Eliminate unnecessary equations
Elimination of unnecessary equations
rows 210, 12, 1420 AA Mat( rows
, ) rhs eq_const( rows , )
24Programming the solution
Solve equations by Gaussian elimination
Solve for forces AA\rhs
25Programming the solution
The Complete Code
clear load Ex1StructJointsMod.dat load
Ex1StructConnectMod.dat num_joints
size(Ex1StructJointsMod,1) num_members
size(Ex1StructConnectMod,1) Matrix with
coordinates of joints coord Ex1StructJointsMod(
,23) Connectivity matrix C
Ex1StructConnectMod(,23) Distance
matrix i X j for i 1num_joints for
j 1num_joints dist(i,j)
((coord(i,1)-coord(j,1))2
(coord(i,2)-coord(j,2))2)(1/2) end end
Unit vector matrices (x-component and
y-component) iXj for i 1num_joints
for j 1num_joints if (dist(i,j) 0)
x_comp(i,j) 0 y_comp(i,j) 0
else
x_comp(i,j) (coord(j,1)-coord(i,1))/dis
t(i,j) y_comp(i,j) (coord(j,2)-coord(i
,2))/dist(i,j) end
end end Matrix construction for linear
system for m 1num_members Mat( C(m,1)
, m) x_comp( C(m,1) , C(m,2) ) Mat( C(m,2)
, m) x_comp( C(m,2) , C(m,1) ) Mat(
C(m,1) num_joints , m) y_comp( C(m,1) ,
C(m,2) ) Mat( C(m,2) num_joints , m)
y_comp( C(m,2) , C(m,1) ) end Equilibrium
constant for net force at each joint eq_const
zeros(2num_joints,1) eq_const(num_joints3)100
Elimination of unnecessary equations
rows 28, 1012, 1416 AA Mat(
rows , ) rhs eq_const( rows , )
Solve for forces AA\rhs
26Programming the solution
The Matlab Output
ans
-70.7107 50.0000 0 -70.7107
0 50.0000 100.0000 -70.7107 0
50.0000 0 -70.7107 50.0000