Create a Matlab program to assemble the Kff matrices for bot

Create a Matlab program to assemble the Kff matrices for both trusses shown in Figs. 1-2. Include a hard copy of your code, as well as upload to Beachboard. You may assume E = 29,000 ksi and A = 10 in^2 for Fig. 2 truss.

Solution

Figure 1

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Finite element program for truss analysis %%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
clc;

%%%%%%%%%%%%% Edit the following data %%%%%%%%%%%%%%
numnode = 4; %number of nodes
numelem = 3; %number of elements
Nodes = [0 0; 12*12 0; 24*12 0; 12*12 16*12]; %x, y coordinates
Elements = [1 4 29e6 8;2 4 29e6 8; 3 4 29e6 8]; % first node, second node, E, A

KG = zeros(2*numnode,2*numnode); % Global stiffness matrix
ElemStiff = zeros(numelem,1); %Basic element stiffness

%%%%%%%%%%%%%%%%%%%%%%% Stiffness Matrix Calculation %%%%%%%%%%%%%%%%%%%%%%
for i = 1:numelem
  
DOFs = [2*Elements(i, 1)-1, 2*Elements(i, 1), 2*Elements(i, 2)-1, 2*Elements(i, 2)]; %Holds element’s DOFs
X1 = Nodes(Elements(i,1), 1);
Y1 = Nodes(Elements(i,1), 2);
X2 = Nodes(Elements(i,2), 1);
Y2 = Nodes(Elements(i,2), 2);
L = sqrt((X2-X1)^2+(Y2-Y1)^2); %Length of each element
s = (Y2-Y1)/L;
c=(X2-X1)/L;
ms = (Y2-Y1)/L;

E = Elements(i,3); %Modulus of elasticiy of element
A = Elements(i,4); %Cross sectional area of element
ElemStiff(i) = A*E/L; % Basic element stiffness for each element
Trans1 = [c 0;s 0;0 c;0 s]; % Transformation matrix
Trans2 = (Trans1)\';
Kelem = Trans1*[ElemStiff(i) -ElemStiff(i);-ElemStiff(i) ElemStiff(i)]*Trans2;% Calculates the element stiffness matrix
KG(DOFs,DOFs) = KG(DOFs,DOFs) + Kelem; % Global stiffness matrix
end
%%%%%%%%%%%%%%%%%%%% End of Stiffness Matrix Calculation %%%%%%%%%%%%%%%%%%

Figure 2

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Finite element program for truss analysis %%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
clc;

%%%%%%%%%%%%% Edit the following data %%%%%%%%%%%%%%
numnode = 5; %number of nodes
numelem = 7; %number of elements
Nodes = [0 0; 3*12 0; 6*12 0; 6*12 4*12; 0 4*12]; %x, y coordinates
Elements = [1 2 29e6 10;2 3 29e6 10; 3 4 29e6 10; 4 5 29e6 10; 5 1 29e6 10; 5 2 29e6 10; 2 4 29e6 10*3/2]; % first node, second node, E, A

KG = zeros(2*numnode,2*numnode); % Global stiffness matrix
ElemStiff = zeros(numelem,1); %Basic element stiffness

%%%%%%%%%%%%%%%%%%%%%%% Stiffness Matrix Calculation %%%%%%%%%%%%%%%%%%%%%%
for i = 1:numelem
  
DOFs = [2*Elements(i, 1)-1, 2*Elements(i, 1), 2*Elements(i, 2)-1, 2*Elements(i, 2)]; %Holds element’s DOFs
X1 = Nodes(Elements(i,1), 1);
Y1 = Nodes(Elements(i,1), 2);
X2 = Nodes(Elements(i,2), 1);
Y2 = Nodes(Elements(i,2), 2);
L = sqrt((X2-X1)^2+(Y2-Y1)^2); %Length of each element
s = (Y2-Y1)/L;
c=(X2-X1)/L;
ms = (Y2-Y1)/L;

E = Elements(i,3); %Modulus of elasticiy of element
A = Elements(i,4); %Cross sectional area of element
ElemStiff(i) = A*E/L; % Basic element stiffness for each element
Trans1 = [c 0;s 0;0 c;0 s]; % Transformation matrix
Trans2 = (Trans1)\';
Kelem = Trans1*[ElemStiff(i) -ElemStiff(i);-ElemStiff(i) ElemStiff(i)]*Trans2;% Calculates the element stiffness matrix
KG(DOFs,DOFs) = KG(DOFs,DOFs) + Kelem; % Global stiffness matrix
end
%%%%%%%%%%%%%%%%%%%% End of Stiffness Matrix Calculation %%%%%%%%%%%%%%%%%%

 Create a Matlab program to assemble the Kff matrices for both trusses shown in Figs. 1-2. Include a hard copy of your code, as well as upload to Beachboard. Yo
 Create a Matlab program to assemble the Kff matrices for both trusses shown in Figs. 1-2. Include a hard copy of your code, as well as upload to Beachboard. Yo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site