Matrix Structural Analysis
Matrix Structural Analysis
ndof=6;
nelem=2;
elemdof=4; %since axial deformation is neglected, otherwise it would be 6
freedof=2;
fixeddof=4;
%Element Properties
A=[1 1];
E=[29000 29000];
I=[560 560]; % I dont know why I am making these types of matrices for element p
roperties
%Truss Geometry
xy=[18*12 0; 20*12 0];
ConMat=[3 4 5 1; 5 1 6 2];
for i = 1:nelem
L(i)=sqrt((xy(i,1)^2)- (xy(i,2)^2));
end
%Element Stiffness Matrix
for i=1:nelem
a=12*E(i)*I(i)/L(i)^3;
b=6*E(i)*I(i)/L(i)^2;
c=4*E(i)*I(i)/L(i);
kbar(i,:,:)=[a b -a b;b c -b c/2;-a -b a -b;b c/2 -b c];%Stiffness is the pr
operty of the structure that does not change depend on loading
%In kbar the matrix, there are two matrices and this is a
%multidimensional or more popularly called 3D matrix
T(i,:,:)= (1/L(i))*[xy(i,1) xy(i,2) 0 0;
-xy(i,2) xy(i,1) 0 0;
0 0 xy(i,1) xy(i,2);
0 0 -xy(i,2) xy(i,1)];
%Transformation Matrix neglecting axial deformation, there are same number
%of transformation matrices stored in variable 'T' as the number of
%elements in the structure considered
end
for i = 1:nelem
Ti = zeros(elemdof, elemdof);%6 by 6 matrix in Ti
for d = 1:elemdof % 1to 6
for f = 1:elemdof % 1to 6
Ti(d,f) = T(i,d,f);
kbari(d,f) = kbar(i,d,f);
end
end
k(i,:,:)=Ti'*kbari*Ti;
end
%Further Code for assembling Global ndof x ndof matrix
K=zeros(ndof,ndof);
for i=1:nelem
Ktemp=zeros(ndof,ndof);
for d = 1:elemdof
for f = 1:elemdof
Ktemp(ConMat(i,d), ConMat(i,f))=k(i,d,f);
end
end
K=K+Ktemp;
end
%Load Vector
FEF1 = [19 1026 19 -1026];
FEF2 = [12 640 28 -960];
FEF= zeros(4,1,2);
FEF(:,:,1)=FEF1;
FEF(:,:,2)=FEF2;
PF = zeros(ndof,1);
for i = 1:nelem
Ftemp = zeros(ndof,1);
for d = 1:elemdof
Ftemp(ConMat(i,d),1) = FEF(d,1,i);
end
PF = PF + Ftemp;
end
FEF=PF;
Kff = K(1:freedof,1:freedof);
Ksf = K(freedof+1:ndof,1:freedof);
Kss = K(freedof+1:ndof,freedof+1:ndof);
Pff = PF(1:freedof,1); % fixed end forces inserted into Pff
FEFsf = FEF(freedof+1:ndof,1);
FEFff = FEF(1:freedof,1);
%Displacements
delta_f = inv(Kff)*((0)-FEFff);
%Reactions
Ps = (Ksf*delta_f) + FEFsf;