User:Eml4500.f08.ateam.didomenico/hw 3



% Matlab Script %********************************************************************* % filename: twobar.m % % PURPOSE: %   Example of Two Bar Truss deformation % % AUTHOR: Daniel DiDomenico % % Modified on: % Created on : Mon, 06 Oct 2008, 11:32:47 EST % % DEPENDENCIES: %  call: % % REMARKS: % %*********************************************************************  clear; close; dof = 2; n_node = 4; n_elem = 4; total_dof = 2 * n_node; position(:, 1) = [ 0; 0]; position(:, 2) = [ 3.4641; 2]; position(:, 3) = [ 4.87831; 0.585786]; position(:, 4) = [ 7.8161; 8.1271]; for i = 1 : n_node; x(i) = position(1,i); y(i) = position(2,i); end node_connect(1, 1) = 1; node_connect(2, 1) = 2; node_connect(1, 2) = 2; node_connect(2, 2) = 3; node_connect(1, 3) = 1; node_connect(2, 3) = 4; node_connect(1, 4) = 4; node_connect(2, 4) = 3; for i = 1 : 2 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([0 10 0 10]) plot(xx,yy,'--') hold on   end for i = 3 : 4 node_3 = node_connect(1,i); node_4 = node_connect(2,i); xx = [x(node_3),x(node_4)]; yy = [y(node_3),y(node_4)]; axis([-2 10 -2 10]) plot(xx,yy,'-r') 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(1,2))/2 + x(node_connect(2,2))/2,y(node_connect(1,2))/2+y(node_connect(2,2))/2,'Element 2','HorizontalAlignment', 'center') text(x(node_connect(2,3)),y(node_connect(1,4)),'Global Node 3','HorizontalAlignment', 'center') text(x(node_connect(2,3))/2,y(node_connect(2,3))/2,'Element 1','HorizontalAlignment', 'center') text(x(node_connect(2,3))/2 + x(node_connect(2,4))/2,y(node_connect(2,3))/2+y(node_connect(2,4))/2,'Element 2','HorizontalAlignment', 'center') title('Two Bar Truss Deformation') xlabel('x') ylabel('y')