# User:Eml4500.f08.ramrod.D/HW5

## Debugged 2 Bar Truss System

Below is the code to the debugged two bar truss system. Since the modulus of elasticity and the areas for the given example were not the same the code had to be modified in order for it to run properly. Before the correction the code was running as if the all of the elements had the same modulus of elasticity and the same area. Below is the corrected code and the results from the corrected code. Functions PlaneTrussElemtens.m, NodalSoln.m and PlaneTrussResults.m were used in this code and the discription for these functions can be found in the functions section.

```% Two bar truss example
clear all;
e = [3 5]; A = [1 2]; P = 7;
L=[4 2];
alpha = pi/3;
beta = pi/4;

nodes = [0, 0;
L(1)*cos(pi/2-alpha), L(1)*sin(pi/2-alpha);
L(1)*cos(pi/2-alpha)+L(2)*sin(beta),L(1)*sin(pi/2-alpha)-L(2)*cos(beta)];

dof=2*length(nodes);

conn=[1,2; 2,3];
lmm = [1, 2, 3, 4; 3, 4, 5, 6];
elems=size(lmm,1);
K=zeros(dof); R = zeros(dof,1);
debc = [1, 2, 5, 6];
ebcVals = zeros(length(debc),1);

R = zeros(dof,1); R(4) = P;

% Assemble global stiffness matrix
K=zeros(dof);
for i=1:elems
lm=lmm(i,:);
con=conn(i,:);
k_local=e(i)*A(i)/L(i)*[1 -1; -1 1]
k=PlaneTrussElement(e(i), A(i), nodes(con,:))
K(lm, lm) = K(lm, lm) + k;
end
K
R
% Nodal solution and reactions
[d, reactions] = NodalSoln(K, R, debc, ebcVals)
results=[];
for i=1:elems
results = [results; PlaneTrussResults(e(i), A(i), ...
nodes(conn(i,:),:), d(lmm(i,:)))];
end
format short g
results
```

Results from the debugged two bar truss code

```k_local =

0.7500   -0.7500
-0.7500    0.7500

k =

0.5625    0.3248   -0.5625   -0.3248
0.3248    0.1875   -0.3248   -0.1875
-0.5625   -0.3248    0.5625    0.3248
-0.3248   -0.1875    0.3248    0.1875

k_local =

5    -5
-5     5

k =

2.5000   -2.5000   -2.5000    2.5000
-2.5000    2.5000    2.5000   -2.5000
-2.5000    2.5000    2.5000   -2.5000
2.5000   -2.5000   -2.5000    2.5000

K =

0.5625    0.3248   -0.5625   -0.3248         0         0
0.3248    0.1875   -0.3248   -0.1875         0         0
-0.5625   -0.3248    3.0625   -2.1752   -2.5000    2.5000
-0.3248   -0.1875   -2.1752    2.6875    2.5000   -2.5000
0         0   -2.5000    2.5000    2.5000   -2.5000
0         0    2.5000   -2.5000   -2.5000    2.5000

R =

0
0
0
7
0
0

d =

0
0
4.3520
6.1271
0
0

reactions =

-4.4378
-2.5622
4.4378
-4.4378

results =

1.7081       5.1244       5.1244
0.6276        3.138        6.276

>>
```

### Comparison of Results

Once the code was corrected the same reaction results were obtained when comparing it to the statics methods that have been done in class. Below are the results to the statics method.

Finite Element Method:

Using this equation, we can now solve for the f(1) matrix and thus we find the values for the reactions:

$f^{(1)}_{1} = F_{1} = -4.4378$

$f^{(1)}_{2} = F_{2} = -2.5622$

Using this same procedure applied to element 2, we can solve for the values of the other two unknown reactions giving us:

$f^{(2)}_{3} = F_{5} = 4.4378$

$f^{(2)}_{4} = F_{6} = -4.4378$

Statics

Using the Euler cut method, you find the following components from the resultant P forces.

$P_x^1 = -4.4378$
$P_y^1=-2.5622$
$P_x^2=4.4378$
$P_y^2=-4.4378$

## Six Bar Truss Example

### Six Bar Truss Code

Below is the code for the six bar truss system found on page 226 in the the textbook. All six of the bars have the same modulus of elasticity (e) and the same area (A). The MATLAB functions of PlaneTrussElement.m, NodalSoln.m, and PlaneTrussResults.m are all found in the code. The descriptions and functions can be found below the results of the six bar truss system.

```% Six bar truss example
e = 200*10^3; A = 0.001*1000^2; P = 20000.;
alpha = pi/6;
nodes = 1000*[0, 0; 4, 0; 0, 3; 4, 3; 2, 2];
dof=2*length(nodes);
conn=[1,2; 2,5; 5,3; 2,4; 1,5; 5,4];
lmm = [1, 2, 3, 4; 3, 4, 9, 10; 9, 10, 5, 6;
3, 4, 7, 8; 1, 2, 9, 10; 9, 10, 7, 8];
elems=size(lmm,1);
K=zeros(dof); R = zeros(dof,1);
debc = [1, 2, 5, 6, 7, 8];
ebcVals = zeros(length(debc),1);

R = zeros(dof,1); R(3) = P*sin(alpha); R(4) = P*cos(alpha);

% Assemble global stiffness matrix
K=zeros(dof);
for i=1:elems
lm=lmm(i,:);
con=conn(i,:);
k=PlaneTrussElement(e, A, nodes(con,:));
K(lm, lm) = K(lm, lm) + k;
end
K
R
% Nodal solution and reactions
[d, reactions] = NodalSoln(K, R, debc, ebcVals)
results=[];
for i=1:elems
results = [results; PlaneTrussResults(e, A, ...
nodes(conn(i,:),:), d(lmm(i,:)))];
end
format short g
results
```

Results of the above code.

```K =

Columns 1 through 5

85355        35355       -50000            0            0
35355        35355            0            0            0
-50000            0        85355       -35355            0
0            0       -35355  1.0202e+005            0
0            0            0            0        71554
0            0            0            0       -35777
0            0            0            0            0
0            0            0       -66667            0
-35355       -35355       -35355        35355       -71554
-35355       -35355        35355       -35355        35777

Columns 6 through 10

0            0            0       -35355       -35355
0            0            0       -35355       -35355
0            0            0       -35355        35355
0            0       -66667        35355       -35355
-35777            0            0       -71554        35777
17889            0            0        35777       -17889
0        71554        35777       -71554       -35777
0        35777        84555       -35777       -17889
35777       -71554       -35777  2.1382e+005            0
-17889       -35777       -17889            0  1.0649e+005

R =

0
0
10000
17321
0
0
0
0
0
0

d =

0
0
0.21311
0.24998
0
0
0
0
-0.0060971
0.012242

reactions =

-10873
-217.27
874.27
-437.13
-1.7279
-16666

results =

5.3276e-005       10.655        10655
-4.6334e-006     -0.92669      -926.69
-4.8873e-006     -0.97746      -977.46
-8.3326e-005      -16.665       -16665
1.5363e-006      0.30727       307.27
-9.659e-009   -0.0019318      -1.9318

>>
```

### Functions

The functions PlaneTrussElement.m, NodalSoln.m, PlaneTrussResults.m were all called in the code for the 5 truss system. They are all necessary for the completion of the truss problem.

PlaneTrussElement.m

This function take the Young's Modulus (e), the Area of the element (A) and the coordinates of the element ends (coord) and generates the stiffness matrix for a plane truss element. The function first calculates the lengths of the the elements. Once those are calculated the stiffness matrix is calculated.

```function k = PlaneTrussElement(e, A, coord)
% PlaneTrussElement(e, A, coord)
% Generates stiffness matrix for a plane truss element
% e = modulus of elasticity
% A = area of cross-section
% coord = coordinates at the element ends

x1=coord(1,1); y1=coord(1,2);
x2=coord(2,1); y2=coord(2,2);
L=sqrt((x2-x1)^2+(y2-y1)^2);
ls=(x2-x1)/L; ms=(y2-y1)/L;
k = e*A/L*[ls^2, ls*ms,-ls^2,-ls*ms;
ls*ms, ms^2,-ls*ms,-ms^2;
-ls^2,-ls*ms,ls^2,ls*ms;
-ls*ms,-ms^2,ls*ms,ms^2];
```

NodalSoln.m

The function takes the global coefficient matrix (K), the global right hand side vector (R), the list of degrees of freedom with specified values, and the specified values to determine the displacements and reactions at each node. The dof of the the system is first found by using the `length` command which finds the longest dimension of R. df then finds the difference between the dofs that have known values (a value of zero) and the dof that were found in the previous line. The displacements and the reactions are then calculated.

```function [d, rf] = NodalSoln(K, R, debc, ebcVals)
% [nd, rf] = NodalSoln(K, R, debc, ebcVals)
% Computes nodal solution and reactions
% K = global coefficient matrix
% R = global right hand side vector
% debc = list of degrees of freedom with specified values
% ebcVals = specified values
dof = length(R);
df = setdiff(1:dof, debc);
Kf = K(df, df);
Rf = R(df) - K(df, debc)*ebcVals;
dfVals = Kf\Rf;
d = zeros(dof,1);
d(debc) = ebcVals;
d(df) = dfVals;
rf = K(debc,:)*d - R(debc);
```

PlaneTrussResults.m

This function computes the plane truss element results. It takes in the modulus of elasticity (e), the area of the cross-section (A), the coordinates at the element ends (coord), and the displacements at the elemtent ends (disps) and calculates the axial strain (eps), stress(sigma) and force (force). The results are stored in the variable `results` and sent back to the main program.

```function results = PlaneTrussResults(e, A, coord, disps)
% results = PlaneTrussResults(e, A, coord, disps)
% Compute plane truss element results
% e = modulus of elasticity
% A = Area of cross-section
% coord = coordinates at the element ends
% disps = displacements at element ends
% The output quantities are eps = axial strain
% sigma = axial stress and force = axial force.

x1=coord(1,1); y1=coord(1,2);
x2=coord(2,1); y2=coord(2,2);
L=sqrt((x2-x1)^2+(y2-y1)^2);
ls=(x2-x1)/L; ms=(y2-y1)/L;
T=[ls,ms,0,0; 0,0,ls,ms];
d = T*disps;
eps= (d(2)-d(1))/L;
sigma = e.*eps;
force = sigma.*A;
results=[eps, sigma, force];
```

### Plot of Six Bar Truss System

Below is the code and the plot of the six bar truss system. The plot was made from the results that were found in the above code. The results demonstrate that only node 2 and node 5 had a displacement of (0.2131, 0.2500) and (-0.0061, 0.0122) respectively. The undeformed system is plotted with the dotted lines and the deformed system is plotted with solid lines. The deformed displacements have been scaled up by a factor of 1.2 in order to enhance in the plot.

```%Plot Six beam truss system
%
clear;
close;

%model with 2-D beam elements
dof = 2; %dof per node: axial disp x, 2= disp y
%obtain the coordinatates of all nodes
%
n_node = 5;             %number of nodes
n_elem = 6;            %number of elements
total_dof = 2 * n_node; %total dof of system

position(:, 1) = [0; 0];
position(:, 2) = [4; 0];
position(:, 3) = [0; 3];
position(:, 4) = [4; 3];
position(:, 5) = [2; 2];
% print the node coord.
for i = 1 : n_node;
x(i) = position (1,i);
y(i) = position (2,i);
end

node_connect (1, 1) = 1;    %element 1
node_connect (2, 1) = 2;

node_connect (1, 2) = 2;    %element 2
node_connect (2, 2) = 5;

node_connect (1, 3) = 3;    %element 3
node_connect (2, 3) = 5;

node_connect (1, 4) = 2;    %element 4
node_connect (2, 4) = 4;

node_connect (1, 5) = 1;    %element 5
node_connect (2, 5) = 5;

node_connect (1, 6) = 5;    %element 6
node_connect (2, 6) = 4;

% connect all beam elements by connectivity array
for i = 1 : n_elem;
node_1 = node_connect(1,i);
node_2 = node_connect(2,i);
xx = [x(node_1),x(node_2)];
yy = [y(node_1),y(node_2)];
axis([ -1 7 -1 5])
plot(xx,yy,'--')
hold on
end

text(x(node_connect(1,1)),y(node_connect(1,1))-.2,'Global Node 1', 'HorizontalAlignment', 'center')
text(x(node_connect(1,2)),y(node_connect(1,2))-.2,'Global Node 2', 'HorizontalAlignment', 'center')
text(x(node_connect(1,3))-.22,y(node_connect(1,3))+.2,'Global Node 3', 'HorizontalAlignment', 'center')
text(x(node_connect(2,4))+.6,y(node_connect(2,4))+.8,'Global Node 4', 'HorizontalAlignment', 'center')
text(x(node_connect(1,6))-1.27,y(node_connect(1,6)),'Global Node 5', 'HorizontalAlignment', 'center')

text (x(node_connect(2,1))*1.1-2,y(node_connect(2,1))/2 -.2,'Element 1', 'HorizontalAlignment', 'center')
text (x(node_connect(2,1))-1.6, y(node_connect(2,1))+1 ,'Element 2', 'HorizontalAlignment', 'center')
text( x(node_connect(2,3))/2 -1, y(node_connect(2,3))/2 ,'Element 3', 'HorizontalAlignment', 'center')
text( x(node_connect(2,4))/2 + 1, y(node_connect(2,4))*1.1 ,'Element 4', 'HorizontalAlignment', 'center')
text( x(node_connect(1,4))*1.5-1.2, y(node_connect(2,3))*.85+.65 ,'Element 5', 'HorizontalAlignment', 'center')
hold on

%Displacements were multiplied by a factor of 1.2 in order for them to show up
%in the plot

position_disp(:, 1) = [0; 0];
position_disp(:, 2) = [5.2133 * 1.2; .25 * 1.2];
position_disp(:, 3) = [0; 3 * 1.2];
position_disp(:, 4) = [4 * 1.2; 3 * 1.2];
position_disp(:, 5) = [1.5439 * 1.2; 2.0122 * 1.2];

% print the node coord.
for i = 1 : n_node;0
x(i) = position_disp (1,i);
y(i) = position_disp (2,i);
end

node_connect_disp (1, 1) = 1;    %element 1
node_connect_disp (2, 1) = 2;

node_connect_disp (1, 2) = 2;    %element 2
node_connect_disp (2, 2) = 5;

node_connect_disp (1, 3) = 3;    %element 3
node_connect_disp (2, 3) = 5;

node_connect_disp (1, 4) = 2;    %element 4
node_connect_disp (2, 4) = 4;

node_connect_disp (1, 5) = 1;    %element 5
node_connect_disp (2, 5) = 5;

node_connect_disp (1, 6) = 5;    %element 6
node_connect_disp (2, 6) = 4;

% connect all beam elements by connectivity array
for i = 1 : n_elem;
node_1 = node_connect_disp(1,i);
node_2 = node_connect_disp(2,i);
xx = [x(node_1),x(node_2)];
yy = [y(node_1),y(node_2)];
axis([ -1 7 -1 5])
plot(xx,yy,'-')
hold on
end

title ('Five Bar Truss System')
xlabel('x')
ylabel('y')
```

File:Six bar truss.JPG
Undeformed and deformed six-bar truss system
 I, the copyright holder of this work, hereby release my work worldwide into the public domain. Where this is not legally possible, I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

## 3 Bar Space Truss

### Three Bar Space Truss Example

Below is the code for the the 3D three bar truss system found in the textbook on page 230. There are four nodes in the system with each node containing 3 degrees of freedom. The code uses three additional functions for it to be run. SpaceTrussElement.m, NodalSoln.m, and NodalSoln.m were all used for the code. Below this code a description of each function can be found.

```% Three bar space truss example
a1 = 200; a2 = 600; e = 200000; P = 20000;
nodes = 1000*[.96, 1.92, 0; -1.44, 1.44, 0; 0, 0, 0; 0, 0, 2];
dof=3*length(nodes);
conn=[1,4; 2,4; 3,4];
lmm = [1, 2, 3, 10, 11, 12;
4, 5, 6, 10, 11, 12;
7, 8, 9, 10, 11, 12];
debc = [1:9];
ebcVals = zeros(length(debc),1);

R = zeros(dof,1); R(11) = -P;

% Assemble global stiffness matrix
K=zeros(dof);
for i=1:2
lm=lmm(i,:);
con=conn(i,:);
k=SpaceTrussElement(e, a1, nodes(con,:));
K(lm, lm) = K(lm, lm) + k;
end
lm=lmm(3,:);
con=conn(3,:);
k=SPaceTrussElement(e, a2, nodes(con,:));
K(lm, lm) = K(lm, lm) + k

% Nodal solution and reactions
[d, reactions] = NodalSoln(K, R, debc, ebcVals)
results=[];
for i=1:2
results = [results; SpaceTrussResults(e, a1, ...
nodes(conn(i,:),:), d(lmm(i,:)))];
end
results = [results; SpaceTrussResults(e, a2, ...
nodes(conn(3,:),:), d(lmm(3,:)))];
format short g
results
```

### Functions

The functions SpaceTrussElement.m, NodalSoln.m, SpaceTrussResults.m were all called in the code for the 5 truss system. They are all necessary for the completion of the truss problem.

SpaceTrussElement.m This function creates the stiffness matrix of a space truss element. It takes in the modulus of elacticity (e), the truss area (A), and the corresponding coordinates for the truss. The function first calculates the length of each element and then calculates the stiffness matrix (k).

```function k = SpaceTrussElement(e, A, coord)
% k = SpaceTrussElement(e, A, coord)
% Generates stiffness matrix of a space truss element
% e = modulus of elasticity
% A = Area of cross-section
% coord = coordinates at the element ends

x1=coord(1,1); y1=coord(1,2); z1=coord(1,3);
x2=coord(2,1); y2=coord(2,2); z2=coord(2,3);
L=sqrt((x2-x1)^2+(y2-y1)^2+(z2-z1)^2);
ls=(x2-x1)/L; ms=(y2-y1)/L; ns=(z2-z1)/L;
k = e*A/L*[ls^2, ls*ms, ls*ns, -ls^2, -(ls*ms), -(ls*ns);
ls*ms, ms^2, ms*ns, -(ls*ms), -ms^2, -(ms*ns);
ls*ns, ms*ns, ns^2, -(ls*ns), -(ms*ns), -ns^2;
-ls^2, -(ls*ms), -(ls*ns), ls^2, ls*ms, ls*ns;
-(ls*ms), -ms^2, -(ms*ns), ls*ms, ms^2, ms*ns;
-(ls*ns), -(ms*ns), -ns^2, ls*ns, ms*ns, ns^2];
```

NodalSoln.m

The function takes the global coefficient matrix (K), the global right hand side vector (R), the list of degrees of freedom with specified values, and the specified values to determine the displacements and reactions at each node. The dof of the the system is first found by using the `length` command which finds the longest dimension of R. df then finds the difference between the dofs that have known values (a value of zero) and the dof that were found in the previous line. The displacements and the reactions are then calculated.

```function [d, rf] = NodalSoln(K, R, debc, ebcVals)
% [nd, rf] = NodalSoln(K, R, debc, ebcVals)
% Computes nodal solution and reactions
% K = global coefficient matrix
% R = global right hand side vector
% debc = list of degrees of freedom with specified values
% ebcVals = specified values
dof = length(R);
df = setdiff(1:dof, debc);
Kf = K(df, df);
Rf = R(df) - K(df, debc)*ebcVals;
dfVals = Kf\Rf;
d = zeros(dof,1);
d(debc) = ebcVals;
d(df) = dfVals;
rf = K(debc,:)*d - R(debc);
```

SpaceTrussResults.m

This function takes in the modulus of elasticity (e), the area of each truss (A), the coordinate of the nodes and the displacements (disps) at the element ends. It calculates the axial strain (eps), stress(sigma) and force (force). The results are stored in the variable `results` and sent back to the main program.

```function results = SpaceTrussResults(e, A, coord, disps)
% results = SpaceTrussResults(e, A, coord, disps)
% Compute space truss element results
% e = modulus of elasticity
% A = Area of cross-section
% coord = coordinates at the element ends
% disps = displacements at element ends

x1=coord(1,1); y1=coord(1,2); z1=coord(1,3);
x2=coord(2,1); y2=coord(2,2); z2=coord(2,3);
L=sqrt((x2-x1)^2+(y2-y1)^2+(z2-z1)^2);
ls=(x2-x1)/L; ms=(y2-y1)/L; ns=(z2-z1)/L;
T=[ls,ms,ns,0,0,0; 0,0,0,ls,ms,ns];
d = T*disps;
eps= (d(2)-d(1))/L;
sigma = e.*eps;
force = sigma.*A;
results=[eps, sigma, force];
```

### 3 Bar Space Truss Results

Below are the results from the three bar space truss example.

```K =

1.0e+004 *

Columns 1 through 7

0.1460    0.2919   -0.3041         0         0         0         0
0.2919    0.5839   -0.6082         0         0         0         0
-0.3041   -0.6082    0.6335         0         0         0         0
0         0         0    0.3567   -0.3567    0.4954         0
0         0         0   -0.3567    0.3567   -0.4954         0
0         0         0    0.4954   -0.4954    0.6880         0
0         0         0         0         0         0         0
0         0         0         0         0         0         0
0         0         0         0         0         0         0
-0.1460   -0.2919    0.3041   -0.3567    0.3567   -0.4954         0
-0.2919   -0.5839    0.6082    0.3567   -0.3567    0.4954         0
0.3041    0.6082   -0.6335   -0.4954    0.4954   -0.6880         0

Columns 8 through 12

0         0   -0.1460   -0.2919    0.3041
0         0   -0.2919   -0.5839    0.6082
0         0    0.3041    0.6082   -0.6335
0         0   -0.3567    0.3567   -0.4954
0         0    0.3567   -0.3567    0.4954
0         0   -0.4954    0.4954   -0.6880
0         0         0         0         0
0         0         0         0         0
0    6.0000         0         0   -6.0000
0         0    0.5026   -0.0647    0.1913
0         0   -0.0647    0.9405   -1.1036
0   -6.0000    0.1913   -1.1036    7.3216

d =

0
0
0
0
0
0
0
0
0
-0.1871
-2.5920
-0.3858

reactions =

1.0e+004 *

0.6667
1.3333
-1.3889
-0.6667
0.6667
-0.9259
0
0
2.3148

results =

0.00050936       101.87        20375
0.00033036       66.072        13214
-0.0001929       -38.58       -23148

>>
```

### Code for the lot of the 3 Bar Space Truss

Below is the code for the 3 Bar Space Truss.

```%Plot three beam truss system
%
clear;
close;

%model with 2-D beam elements
dof = 3; %dof per node: axial disp x, 2= disp y
%obtain the coordinatates of all nodes
%
n_node = 4;             %number of nodes
n_elem = 3;            %number of elements
total_dof = 3 * n_node; %total dof of system

position(:, 1) = [-.96; 1.92; 0 ];
position(:, 2) = [-1.44; 1.44; 0 ];
position(:, 3) = [0; 0; 0 ];
position(:, 4) = [0; 0; 2]
% print the node coord.
for i = 1 : n_node;
x(i) = position (1,i);
y(i) = position (2,i);
z(i) = position (3,i);
end

node_connect (1, 1) = 1;    %element 1
node_connect (2, 1) = 4;

node_connect (1, 2) = 2;    %element 2
node_connect (2, 2) = 4;

node_connect (1, 3) = 3;    %element 3
node_connect (2, 3) = 4;

% connect all beam elements by connectivity array
for i = 1 : n_elem;
node_1 = node_connect(1,i);
node_2 = node_connect(2,i);
xx = [x(node_1),x(node_2)];
yy = [y(node_1),y(node_2)];
zz = [z(node_1),z(node_2)];
axis([ -3 3 -3 3 -3 3])
plot3(xx,yy,zz,'--')
view([1,1,1])
hold on
end

text(x(node_connect(1,1)),y(node_connect(1,1)),z(node_connect(1,1))-.5,'Global Node 1', 'HorizontalAlignment', 'center')
text(x(node_connect(1,2))-1,y(node_connect(1,2)),z(node_connect(1,2))+.3,'Global Node 2', 'HorizontalAlignment', 'center')
text(x(node_connect(1,3)),y(node_connect(1,3)),z(node_connect(1,3))-.5,'Global Node 3', 'HorizontalAlignment', 'center')
text(x(node_connect(2,3)),y(node_connect(2,3)),z(node_connect(2,3))+.5,'Global Node 4', 'HorizontalAlignment', 'center')

%text (x(node_connect(1,1))/2,y(node_connect(1,1))/2 +1,'Element 1', 'HorizontalAlignment', 'center')
%text (x(node_connect(2,2))/2 -1, y(node_connect(2,2))/2 -.5,'Element 2', 'HorizontalAlignment', 'center')
%text( x(node_connect(2,3))/2, y(node_connect(2,3))*.75 ,'Element 3', 'HorizontalAlignment', 'center')

%Scaled by 1/10

position_disp(:, 1) = [-.96; 1.92; 0 ];
position_disp(:, 2) = [-1.44; 1.44; 0 ];
position_disp(:, 3) = [0; 0; 0 ];
position_disp(:, 4) = [-0.1871; -2.5920; 2 + -0.3858]

% print the node coord.
for i = 1 : n_node;0
x(i) = position_disp (1,i);
y(i) = position_disp (2,i);
z(i) = position_disp (3,i);
end

node_connect_disp (1, 1) = 1;    %element 1
node_connect_disp (2, 1) = 4;

node_connect_disp (1, 2) = 2;    %element 2
node_connect_disp (2, 2) = 4;

node_connect_disp (1, 3) = 3;    %element 3
node_connect_disp (2, 3) = 4;

% connect all beam elements by connectivity array
for i = 1 : n_elem;
node_1 = node_connect_disp(1,i);
node_2 = node_connect_disp(2,i);
xx = [x(node_1),x(node_2)];
yy = [y(node_1),y(node_2)];
zz = [z(node_1),z(node_2)];
axis([ -3 3 -3 3 -3 3])
view([1,1,1])
plot3(xx,yy,zz,'-')
hold on
end

title ('Three Bar Space Truss System')
xlabel('x')
ylabel('y')
zlabel('z')
```

### Plot of 3 Bar Space Truss

Below is the plot of the 3 bar Space truss with the viewing mode of x = 1m, y = 1m, and z= 1m. The dotted lines represent the undeformed truss system and the solid lines represent the deformed truss system.

File:3barspace111.JPG
Undeformed and deformed three bar space truss with a viewing mofe of [1 1 1]
 I, the copyright holder of this work, hereby release my work worldwide into the public domain. Where this is not legally possible, I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

Below is the same plot but in plane view down the x axis, plane view down the y axis, and plane view down the z axis.

File:3barspacex.JPG
Undeformed and deformed three bar space truss with a viewing down plane x
 I, the copyright holder of this work, hereby release my work worldwide into the public domain. Where this is not legally possible, I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.
File:3barspacey.JPG
Undeformed and deformed three bar space truss with a viewing down plane y
 I, the copyright holder of this work, hereby release my work worldwide into the public domain. Where this is not legally possible, I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.
File:3barspacez.JPG
Undeformed and deformed three bar space truss with a viewing down plane z
 I, the copyright holder of this work, hereby release my work worldwide into the public domain. Where this is not legally possible, I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.