You are on page 1of 3

x=[0 10 30 60 100 0 17.5 40 67.5 100 0 25 50 75 100 0 32.5 60 82.

5 100 0 40 70 90 100];
y=[0 0 0 0 0 25 25 25 25 25 50 50 50 50 50 75 75 75 75 75 100 100 100 100 100];
syms r s Xc Yc;
syms r s;
L=100;n=4; %no.of elements
E=10; %E is Youngs Modulus
neu=0.25; %poissons ratio
% find the jacobian and matrix A for each of the element--------------------------->>
% J=[L/(2*n) 0;0 L/(2*n)]; %J is jacobian
Kg=zeros(2*(n+1)*(n+1),2*(n+1)*(n+1));
D=E/(1-neu^2)*[1 neu 0;neu 1 0;0 0 (1-neu)/2];
% A=[1/125 0 0 0;0 0 0 1/125;0 1/125 1/125 0];
N1=(1-r)*(1-s)/4;
N2=(1+r)*(1-s)/4;
N3=(1-r)*(1+s)/4;
N4=(1+r)*(1+s)/4;
i=1;
for k=1:n*n
C(k,1)=2*i-1;C(k,2)=2*i;
C(k,3)=2*(i+1)-1;C(k,4)=2*(i+1);
m=n-4;
C(k,5)=2*(i+m+6)-1;C(k,6)=2*(i+m+6);
C(k,7)=2*(i+m+5)-1;C(k,8)=2*(i+m+5);
i=i+1;
if rem(k,n)==0

i=i+1;
end
end
C
iteration=0;
for i=1:n*n
if rem(k,n)==0
i=i+1;
end
Xc=N1*x(i)+N2*x(i+1)+N3*x(i+6)+N4*x(i+5);
Yc=N1*y(i)+N2*y(i+1)+N3*y(i+6)+N4*y(i+5);
if rem(k,n)==0
i=i-1;
end
J=[diff(Xc,r,1) diff(Yc,r,1);diff(Xc,s,1) diff(Yc,s,1)];
A=1/det(J)*[J(2,2) -J(1,2) 0 0;0 0 -J(2,1) J(1,1);-J(2,1) J(1,1) J(2,2) -J(1,2)];
G=(1/4)*[-(1-s) 0 1-s 0 -(1+s) 0 1+s 0;-(1-r) 0 -(1+r) 0 (1-r) 0 1+r 0;0 -(1-s) 0 1-s 0 -(1+s) 0 1+s;0 -(1-r) 0 (1+r) 0 (1-r) 0 1+r];
B=A*G;
K=B'*D*B*det(J);
KE=zeros(length(K),length(K));
P=[1/sqrt(3) -1/sqrt(3)];
for j=1:2
for k=1:2
Ks=subs(K,r,P(j));Ks=subs(Ks,s,P(k));
KE=KE+Ks;

end
end
for p=1:8
for q=1:8
Kg(C(i,p),C(i,q))=Kg(C(i,p),C(i,q))+KE(p,q);
end
end
iteration=iteration+1
end
NF=[1 2 11 12 21 22 31 32 41 42];
for i=1:length(NF)
Kglobal(NF(i),NF(i))=1; %making diagnol element 1
Kglobal(NF(i),NF(i)+1:o)=0; %making other terms in that
Kglobal(NF(i)+1:o,NF(i))=0;
if NF(i)~=1 || NF(i)~=o
Kglobal(NF(i),1:(NF(i)-1))=0;
Kglobal(1:(NF(i)-1),NF(i))=0;
end
end

%row and column as zero

You might also like