User:Eml4500.f08.bottle.loschak/HW3

HW 3 work matlab problem

% Matlab coding for HW 3 problem % For HW3, write a matlab code to plot the initial underformed % configuration of the two-bar truss system solved in class in % dotted line, and then superpose on the same figure the deformed % configuration in solid line. clear; close; % L(1) = 4 % theta(1) = 30 % k(1) = 3/4 % AC = 6.8324 % L(2) = 2 % theta(2) = -45 % k(2) = 5 % AB = 1.255 n_node = 8; n_elem = 6; P1_1 = 5.1243; P1_2 = 6.276; k_1 = .75; k_2 = 5; AC = P1_1/k_1; AB = P1_2/k_2; position(:,1) = [0; 0; 0]; position(:,2) = [4*cos(.5236); 4*sin(.5236); 0]; position(:,3) = [4*cos(.5236)+2*cos(.7854); 4*sin(.5236)-2*sin(.7854); 0]; position(:,4) = [4*cos(.5236)-1.255*cos(.7854); 4*sin(.5236)+1.255*sin(.7854); 0]; position(:,5) = [4*cos(.5236)+6.8324*cos(.5236); 4*sin(.5236)+6.8324*sin(.5236); 0]; position(:,6) = [4*cos(.5236)+6.8324*cos(.5236)-4*cos(1.047); 4*sin(.5236)+6.8324*sin(.5236)+4*sin(1.047); 0]; position(:,7) = [4*cos(.5236)-1.255*cos(.7854)+8*cos(.7854); 4*sin(.5236)+1.255*sin(.7854)+8*cos(.7854); 0]; position(:,8) = [7.8157; 8.1264; 0];   % intersection between AC and AB                                         % determined by zooming on graph % intersection 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; node_connect(2,1) = 2; node_connect(1,2) = 2; node_connect(2,2) = 3; node_connect(1,3) = 2; node_connect(2,3) = 4; node_connect(1,4) = 2; node_connect(2,4) = 5; node_connect(1,5) = 4; node_connect(2,5) = 7; node_connect(1,6) = 5; node_connect(2,6) = 6; node_connect(1,7) = 1; node_connect(2,7) = 8; node_connect(1,8) = 3; node_connect(2,8) = 8; 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([-1 10 -1 10]) plot3(xx,yy,zz,':') hold on end for i = 7 : 8; 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)]; plot3(xx,yy,zz,'-') hold on end title('Deformed and undeformed two-bar truss system') xlabel('x') ylabel('y') zlabel('z') view([0 0 1])     % xy plane view