User:Eml4500.f08.ramrod.D/HW3

MATLAB Code to Plot Undeformed and Deformed Two Bar Truss System
The code below plots the two bar truss system that was solved in class with the deformed system superimposed on top. The plot of the system is below the code.

% Matlab Script %********************************************************************* % filename: two_bar_truss.m  % % PURPOSE: %  Plot the two bar truss system discussed in class and the deformed %  system with matlab % % AUTHOR: %   Daniel Olivero %   Team Ramrod %   EML 4500 FEAD, Fall 2008. % % Modified on: vql, Fri, 03 Oct 2003, 08:37:46 EDT % Created on : Sun, 05 Oct 2008, 16:22:00 EDT % % DEPENDENCIES: %  call: % % REMARKS: % %*********************************************************************  %Plot Two 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 = 3;             %number of nodes n_elem = 2;           %number of elements total_dof = 2 * n_node; %total dof of system

position(:, 1) = [0; 0]; position(:, 2) = [3.46; 2]; position(:, 3) = [4.9; .59];

% 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) = 3;

% 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([ -2 5 -2 5]) plot(xx,yy,'--') hold on end

text(x(node_connect(1,1)),y(node_connect(1,1)),'Global Node 1', 'HorizontalAlignment', 'center') text(x(node_connect(2,1)),y(node_connect(2,1)),'Global Node 2', 'HorizontalAlignment', 'center') text(x(node_connect(2,2)),y(node_connect(2,2)),'Global Node 3', 'HorizontalAlignment', 'center') text(x(node_connect(2,1))/2,y(node_connect(2,1))/2,'Element 1', 'HorizontalAlignment', 'center') text( x(node_connect(2,1)) + (x(node_connect(2,2))-x(node_connect(2,1)))/2, y(node_connect(2,1)) +(y(node_connect(2,2))-y(node_connect(2,1)))/2,'Element 2', 'HorizontalAlignment', 'center')

hold on

position_disp(:,1) = [0;0]; position_disp(:,2) = [7.812; 8.1271]; position_disp(:,3) = [4.9; .59];

% print the node coord. for i = 1 : n_node; 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) = 3;

% 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([ -2 10 -2 10]) plot(xx,yy,'-') hold on end

text(x(node_connect_disp(2,1)),y(node_connect_disp(2,1)),'Global Node 2', 'HorizontalAlignment', 'center') text(x(node_connect_disp(2,1))/2,y(node_connect_disp(2,1))/2,'Element 1', 'HorizontalAlignment', 'center') text( x(node_connect_disp(2,1)) + (x(node_connect_disp(2,2))-x(node_connect_disp(2,1)))/2, y(node_connect_disp(2,1)) +(y(node_connect_disp(2,2))-y(node_connect_disp(2,1)))/2,'Element 2', 'HorizontalAlignment', 'center')

title ('Two Barr Truss System') xlabel('x') ylabel('y')