%-------generating K by Local element stiffness matrix A---------
function G = GK(A,m,L,E,p)
%m=input('divide m = ')
%A=[1,-1;-1,1];
deltaX=L/m;
j=length(A(1,:))-1;
G=zeros(m,m);
x=zeros(m,1);
XO=zeros(m,1);
for i=1:m-1
G(i:i+j,i:i+j)=G(i:i+j,i:i+j)+A;
end
G=G*E*m/L;
b(m,1)=p*(L/m);
q=1;
while q<100
for i=1:m
x(i)=((-1)*(G(i,1:i-1)*x(1:i-1)+G(i,i+1:m)*XO(i+1:m))+b(i))/G(i,i);
end
q=q+1;
for i=1:m
XO(i)=x(i);
end
end
x
沒有留言:
張貼留言