% Matlab Code - Constant Strain Traingle
% Matlab Code - Constant Strain Traingle
m 1 of 3
22 14 20 19 300 120000
23 14 15 20 300 120000
24 12 21 20 300 120000
25 15 16 21 300 120000
26 16 22 21 300 120000
27 16 17 22 300 120000
28 17 23 22 300 120000
29 17 18 23 300 120000
30 18 24 23 300 120000
];
Kgl(1:tdof,1:tdof)=0;
for i=1:length(ECM(:,1))
x13(i)=ND(ECM(i,4),2)-ND(ECM(i,2),2);
y13(i)=ND(ECM(i,4),3)-ND(ECM(i,2),3);
x23(i)=ND(ECM(i,4),2)-ND(ECM(i,3),2);
y23(i)=ND(ECM(i,4),3)-ND(ECM(i,3),3);
J=[x13(i),y13(i);x23(i),y23(i)];
y31(i)=ND(ECM(i,2),3)-ND(ECM(i,4),3);
y12(i)=ND(ECM(i,3),3)-ND(ECM(i,2),3);
x32(i)=ND(ECM(i,3),2)-ND(ECM(i,4),2);
x21(i)=ND(ECM(i,2),2)-ND(ECM(i,3),2);
B=(1/det(J))*[y23(i),0,y31(i),0,y12(i),0;0,x32(i),0,x13(i),0,x21(i);x32(i),y23
(i),x13(i),y31(i),x21(i),y12(i)];
A(i)=0.5*abs(det(J));
t(i)=ECM(i,5);
D=(E/1-(u^2))*[1,u,0;u,1,0;0,0,(0.5-u/2)];
Kele=t(i)*A(i)*B'*D*B;
node1(i)=ECM(i,2);
node2(i)=ECM(i,3);
node3(i)=ECM(i,4);
t1=node1(i)*ndof;
t2=node2(i)*ndof;
t3=node3(i)*ndof;
Kgl((t1-1):t1,(t1-1):t1)=Kgl((t1-1):t1,(t1-1):t1)+Kele(1:2,1:2);
Kgl((t1-1):t1,(t2-1):t2)=Kgl((t1-1):t1,(t1-1):t1)+Kele(1:2,3:4);
Kgl((t1-1):t1,(t3-1):t3)=Kgl((t1-1):t1,(t1-1):t1)+Kele(1:2,5:6);
Kgl((t2-1):t2,(t1-1):t1)=Kgl((t2-1):t2,(t2-1):t2)+Kele(3:4,1:2);
Kgl((t2-1):t2,(t2-1):t2)=Kgl((t2-1):t2,(t2-1):t2)+Kele(3:4,3:4);
Kgl((t2-1):t2,(t3-1):t3)=Kgl((t2-1):t2,(t2-1):t2)+Kele(3:4,5:6);
Kgl((t3-1):t3,(t1-1):t1)=Kgl((t3-1):t3,(t3-1):t3)+Kele(5:6,1:2);
Kgl((t3-1):t3,(t2-1):t2)=Kgl((t3-1):t3,(t3-1):t3)+Kele(5:6,3:4);
Kgl((t3-1):t3,(t3-1):t3)=Kgl((t3-1):t3,(t3-1):t3)+Kele(5:6,5:6);
end
fprintf('-------------------------------------------------------------\n')
ncons=input('Enter the number of nodes with constraints\n');
fprintf('\n Constraints\n');
for i=1:ncons
Bound(i,1)=input('Enter the node\n');
Bound(i,2)=input('Enter displacement in Horizontal direction\n');
Bound(i,3)=input('Enter displacement in Vertical direction\n');
end
fprintf('-------------------------------------------------------------\n')
nknowns=input('Enter the number of nodes with external forces\n');
fprintf('\nForces\n');
for i=1:nknowns
28/2/11 3:16 PM C:\Users\SAICHARAN\Documents\MATLAB\CST.m 3 of 3