User:Eml4500.f08.team.foskey.ckf/hw4matlab

 Comment: This MATLAB portion of HW4 was not included in the original submission. The email stating that this problem was required was misread. Eml4500.f08.team.foskey.ckf 03:32, 5 November 2008 (UTC)

MATLAB Assignment The five bar truss

The Five Bar Truss Problem
The Five Bar Truss problem is from Example 1.4 on page 25 of the text Fundamental Finite Element Analysis and Applications by M. Asghar Bhatti. The code for analyzing the truss was provided, with the intent being to study the code, plot the trusses, and learn how to write code for future problems.

The setup of the Five Bar Truss can be seen below.



The given values for the problem are as follows:

Cross Sectional Areas of Elements
 * Element 1: 40 cm2
 * Element 2: 40 cm2
 * Element 3: 40 cm2
 * Element 4: 40 cm2
 * Element 5: 40 cm2

Young's Modulus
 * Element 1: 200 GPa
 * Element 2: 200 GPa
 * Element 3: 200 GPa
 * Element 4: 200 GPa
 * Element 5: 70 GPa

Applied Load P = 150 kN

Provided Code
The following code was obtained from the textbook's supplemental material website

Comments On The Provided MATLAB Code
The provided code begins by declaring all of the initial property values of the elements, and the applied load. The code also creates the connectivity and location matrix master arrays. The code then loops through the elements (based upon how the elemental properties were declared) to create elemental stiffness matrices. The applied force matrix is then created. Next, the code runs the NodalSoln function to calculate the displacements and reactions. To finish the code, the PlaneTrussResults function is run in a series of loops (again, dictated by the way the element properties were defined) to calculate the strain, stress, and axial forces in the elements.

The functions NodalSoln, PlaneTrussResults, and PlaneTrussElement are needed in addition to the above code in order for the code to run. Those functions and their explanations can be found here.

Plotting Code
The following code uses the provided code above to calculate needed values, then plots the undeformed and deformed trusses.

Comments On The Plotting Code
The above plotting code is used with the provided code to plot the deformed and undeformed trusses. The plotting code begins by running the provided code, called "fivebartruss_originalcode". ( A copy of the original provided code found near the top of this page was saved as a file called "fivebartruss_originalcode.m" so that any changes made to the original code that caused errors would not cause any errors in the plotting.) By running the provided code, all of the needed values are calculated and kept in memory by MATLAB. Once the original code has run, the plotting code rescales all of the nodal coordinates from millimeters to meters, and then calculates the lengths of the elements. The plotting code then assigns each node a position, and then assigns each element end a position. The code then plots the undeformed truss and the deformed truss in a connect-the-dots style by looping through the position numbers. To end the plotting code, the element and node numbers labeled on the figure, and a legend is created.

Results Output
The following results output can be obtained from either the original provided code, or from the plotting code.

Comments On The Results Output
The results output shows the global stiffness matrix K, the force matrix R, the global displacement matrix d, the reactions matrix reactions, and a results matrix. The matrix results shows the axial strain, axial stress, and axial forces of each element in columns 1, 2 and 3 (respectively). Each row represents an element, with row 1 corresponding to element 1, and row 5 corresponding to element 5.

The units of the output values are as follows:

Global Stiffness Matrix K : Newtons per meter (N/m) Applied Loads R : Newtons (N) Global Displacements d : millimeters (mm) Reaction Forces reactions : Newtons (N) Results results : Dimensionless (m/m) for strain, Pascals (pa) for stress, and Newtons (N) for axial force

Figure
The figure generated by the plotting code can be seen below. The undeformed truss (before loading) is seen in red dotted lines, and the deformed truss (after loading) is shown in blue solid lines. The elements are labeled near the midpoints of the undeformed elements, but moved slightly so that they were not ambiguous. The undisplaced nodes are labeled in red, and the displaced nodes (nodes 2 and 3) are labeled in blue. Nodes 1 and 4 are fixed points, and are only labeled once.