0% found this document useful (0 votes)
103 views

% Matlab Code - Constant Strain Traingle

The document contains MATLAB code for analyzing the response of a structure undergoing constant strain triangle loading. It defines variables like the number of elements, material properties, node displacements, element connectivity, and calculates the global stiffness matrix. It then applies boundary conditions and external forces, computes the reduced stiffness matrix and displacement solution.

Uploaded by

Sai Charan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views

% Matlab Code - Constant Strain Traingle

The document contains MATLAB code for analyzing the response of a structure undergoing constant strain triangle loading. It defines variables like the number of elements, material properties, node displacements, element connectivity, and calculates the global stiffness matrix. It then applies boundary conditions and external forces, computes the reduced stiffness matrix and displacement solution.

Uploaded by

Sai Charan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

28/2/11 3:16 PM C:\Users\SAICHARAN\Documents\MATLAB\CST.

m 1 of 3

% MATLAB CODE - CONSTANT STRAIN TRAINGLE


clear all;
clc;
n=24;
n1=30;
u=0.3;
fck=30;
E=5000*sqrt(fck);
ndof=2;
tdof=n*ndof;
ND=[1 0 0
2 800 0
3 1600 0
4 2400 0
5 3200 0
6 4000 0
7 0 1333.33
8 800 1333.33
9 1600 1333.33
10 2400 1333.33
11 3200 1333.33
12 4000 1333.33
13 0 2666.67
14 800 2666.67
15 1600 2666.67
16 2400 2666.67
17 3200 2666.67
18 4000 2666.67
19 0 4000
20 800 4000
21 1600 4000
22 2400 4000
23 3200 4000
24 4000 4000];
ECM=[1 1 2 7 300 120000
2 2 8 7 300 120000
3 2 3 8 300 120000
4 3 9 8 300 120000
5 3 4 9 300 120000
6 4 10 9 300 120000
7 4 5 10 300 120000
8 5 11 10 300 120000
9 5 6 11 300 120000
10 6 12 11 300 120000
11 7 8 13 300 120000
12 8 14 13 300 120000
13 8 9 14 300 120000
14 9 15 14 300 120000
15 9 10 15 300 120000
16 10 16 15 300 120000
17 10 11 16 300 120000
18 11 17 16 300 120000
19 11 12 17 300 120000
20 12 18 17 300 120000
21 13 14 19 300 120000
28/2/11 3:16 PM C:\Users\SAICHARAN\Documents\MATLAB\CST.m 2 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

Force(i,1)=input('Enter the node\n');


Force(i,2)=input('Enter the force in horizonal direction\n');
Force(i,3)=input('Enter the force in vertical direction\n');
end
F1(1:tdof,1)=0;
for i=1:nknowns
F1((Force(i,1)*2-1),1)=Force(i,2);
F1((Force(i,1)*2),1)=Force(i,3);
end
l(1,1:tdof)=1;
L1=logical(l);
for i=1:length(Bound)
if(Bound(i,2)==0)
L1((Bound(i,1)*2)-1)=0;
end
if(Bound(i,3)==0)
L1(Bound(i,1)*2)=0;
end
end
Kred=Kgl(L1,L1);
Fred=F1(L1,1);
disp=inv(Kred)*Fred;
j=1;
for i=1:tdof
if(L1(i)==0)
u1(i,2)=0;
u1(i,1)=i;
elseif(L1(i)>0)
u1(i,2)=disp(j);
u1(i,1)=i;
j=j+1;
end
end

You might also like