You are on page 1of 2

clear;

clc;
format short e
ne=input('ingrese numero de elementos=');
nn=input('ingrese numero de nodos=');
K=zeros(nn*3,nn*3);
KK=zeros(nn*3,nn*3);
for i=1:ne
fprintf('############################################ ELEMENTO %2.0f
##############################################\n',i)
m=input('Del nodo =');
n=input('Al nodo =');
p1=input('coordenadas del nudo inicial en vector [xi yi zi]=')
p2=input('coordenadas del nudo final en vector [xj yj zj]=')
x1=p1(1,1);y1=p1(1,2);z1=p1(1,3)
x2=p2(1,1);y2=p2(1,2);z2=p2(1,3)
l=((x1-x2)^2+(y1-y2)^2+(z1-z2)^2)^.5
cx=(x2-x1)/l;
cy=(y2-y1)/l;
cz=(z2-z1)/l;
C=[cx cy cz 0 0 0;...
0 0 0 cx cy cz];
a=input('AREA de elemento=');
e=input('modulo de elasticidad del elemento=');
ke(1,1)=e*a/l*1;
ke(1,2)=e*a/l*-1;
ke(2,1)=ke(1,2);
ke(2,2)=ke(1,1);
kg=C'*ke*C;
fprintf('longitud de barra=%5.3f \n',l)
fprintf('cosenos directores= %3.3f %3.3f %3.3f
\n',acos(cx)*180/pi,acos(cy)*180/pi,acos(cz)*180/pi);
ke
C
kg

KK(3*m-2,3*m-2)=kg(1,1); KK(3*m-2,3*m-1)=kg(1,2); KK(3*m-2,3*m)=kg(1,3);


KK(3*m-2,3*n-2)=kg(1,4); KK(3*m-2,3*n-1)=kg(1,5); KK(3*m-2,3*n)=kg(1,6);
KK(3*m-1,3*m-2)=kg(2,1); KK(3*m-1,3*m-1)=kg(2,2); KK(3*m-1,3*m)=kg(2,3);
KK(3*m-1,3*n-2)=kg(2,4); KK(3*m-1,3*n-1)=kg(2,5); KK(3*m-1,3*n)=kg(2,6);
KK(3*m,3*m-2)=kg(3,1); KK(3*m,3*m-1)=kg(3,2); KK(3*m,3*m)=kg(3,3);
KK(3*m,3*n-2)=kg(3,4); KK(3*m,3*n-1)=kg(3,5); KK(3*m,3*n)=kg(3,6);
KK(3*n-2,3*m-2)=kg(4,1); KK(3*n-2,3*m-1)=kg(4,2); KK(3*n-2,3*m)=kg(4,3);
KK(3*n-2,3*n-2)=kg(4,4); KK(3*n-2,3*n-1)=kg(4,5); KK(3*n-2,3*n)=kg(4,6);
KK(3*n-1,3*m-2)=kg(5,1); KK(3*n-1,3*m-1)=kg(5,2); KK(3*n-1,3*m)=kg(5,3);
KK(3*n-1,3*n-2)=kg(5,4); KK(3*n-1,3*n-1)=kg(5,5); KK(3*n-1,3*n)=kg(5,6);
KK(3*n,3*m-2)=kg(6,1); KK(3*n,3*m-1)=kg(6,2); KK(3*n,3*m)=kg(6,3);
KK(3*n,3*n-2)=kg(6,4); KK(3*n,3*n-1)=kg(6,5); KK(3*n,3*n)=kg(6,6);

K=K+KK
KK=zeros(nn*3,nn*3);
ke=zeros(2,2)
kg=zeros(6,6);

end
disp('la matriz global es=')
disp(K)

You might also like