Professional Documents
Culture Documents
0 1121 10011
0 2231 25000
0 3341 3 10 0 0 0
-50 4451 4 15 0 0 0
0 5561 5 20 0 1 1
-150 6671 6 15 5 0 0
0 7781 7 10 5 0 0
0 9281
0 10 3 7 1
0 11 4 6 1
0 12 3 8 1
0 13 2 7 1
0 14 4 7 1
0 15 3 6 1
Code
clear all;
clc;
m=dlmread('member.txt');
n=dlmread('nodes.txt');
A=dlmread('load.txt');
o1=size(n);
ms1=o1(1); %number of nodes in the truss system
q=zeros(2*ms1,1); %matrix indicating the direction corresponding to node
are free(0) or restricted(1)
for i=1:ms1
q(2*i-1)=n(i,4);
q(2*i)=n(i,5);
end
l1=length(q); %total number of allowable directions avilaible(twice of
number of nodes for truss system)
o=size(m);
ms=o(1); %number of memebers in the system
s=zeros(2*ms1,2*ms1);
for i=1:ms %formation of stiffness matrix s
j=m(i,2);k=m(i,3);AE=m(i,4); xk=n(k,2);xj=n(j,2);yk=n(k,3);yj=n(j,3);
l(i)=((xk-xj)^2+(yk-yj)^2)^.5;
sina(i)=(yk-yj)/l(i);
cosa(i)=(xk-xj)/l(i);
sm(:,:,i)=[AE/l(i) 0 -AE/l(i) 0; 0 0 0 0; -AE/l(i) 0 AE/l(i) 0; 0 0 0
0];
R=[cosa(i) sina(i); -sina(i) cosa(i)];
T(:,:,i)=[R(1,1) R(1,2) 0 0; R(2,1) R(2,2) 0 0;0 0 R(1,1) R(1,2); 0 0
R(2,1) R(2,2)];
ss(:,:,i)=T(:,:,i)'*sm(:,:,i)*T(:,:,i);
s(2*j-1:2*j, 2*j-1:2*j)=s(2*j-1:2*j, 2*j-1:2*j)+ss(1:2,1:2,i);
s(2*j-1:2*j, 2*k-1:2*k)=s(2*j-1:2*j, 2*k-1:2*k)+ss(1:2,3:4,i);
s(2*k-1:2*k, 2*j-1:2*j)=s(2*k-1:2*k, 2*j-1:2*j)+ss(3:4,1:2,i);
s(2*k-1:2*k, 2*k-1:2*k)=s(2*k-1:2*k,2*k-1:2*k)+ss(3:4,3:4,i);
end
t=1;
for i=1:l1 %arranging stiffness matrix and load matrix with restricted dof
in the beginning
if q(i)==1;
t=t+1;
else
p=A(t); p1=s(:,t);
A(t:l1-1)=A(t+1:l1);
s(:,t:l1-1)=s(:,t+1:l1);
s(:,l1)=p1;
p2=s(t,:); s(t:l1-1,:)=s(t+1:l1,:);
A(l1)=p;
s(l1,:)=p2;
end
end
Af = dr = df = Ar =
0 0 1.0e+03 * 167.8270
-50 0 137.5000
0 0 -0.1516 -167.8270
0 -0.0829
-100 -4.5712
0 0.0266
0 -3.8630
0 -0.9287
0 -3.2268
0 0.0601
0 -4.2147
0.9648
-2.9093