L1=[1 33 34 2 35 36 3 37 38 4 39 40];
L2=[3 37 38 4 39 40 5 41 42 6 43 44];
L3=[5 41 42 6 43 44 7 45 46 8 47 48];
L4=[7 45 46 8 47 48 9 49 50 10 51 52];
L5=[9 49 50 10 51 52 11 53 54 12 55 56];
L6=[11 53 54 12 55 56 13 57 58 14 59 60];
L7=[13 57 58 14 59 60 15 61 62 16 63 64];
L8=[15 61 62 16 63 64 17 65 66 18 67 68];
L9=[17 65 66 18 67 68 19 69 70 20 71 72];
L10=[19 69 70 20 71 72 21 22 23 24 25 26];
L11=[21 22 23 24 25 26 27 28 29 30 31 32];
L=[L1;L2;L3;L4;L5;L6;L7;L8;L9;L10;L11];
fem_all=zeros(11,12);
fem_all(1,1)=-13000;
fem_all(1,7)=-13000;
fem_all(1,4)=2000;
fem_all(1,10)=-2000;
fem_all(end-1,1)=14000;
fem_all(end-1,7)=14000;
fem_all(end-1,4)=450;
fem_all(end-1,10)=450;
fem_all(end,1)=-1234;
fem_all(end,7)=-1234;
uu=32;
ur=40;
Start_r=uu+1;
End_r=uu+ur;
ur1=Start_r:1:End_r;
SC1=rand(11,1);
SC2=rand(11,1);
SC3=rand(11,1);
SC4=rand(11,1);
SC5=rand(11,1);
SC6=rand(11,1);
SC7=rand(11,1);
SC8=rand(11,1);
n=size(SC8,1);
uru=ur+uu;
p1=uu-13;
p2=uu-12;
p3=p1+2;
p4=p2+4;
p5=p1+8;
fem_added=zeros(uru,1);
fem_added(1,1)=-13000;
fem_added(2,1)=2000;
fem_added(3,1)=-13000;
fem_added(4,1)=-2000;
fem_added(p1,1)=14000;
fem_added(p2,1)=450;
fem_added(p3,1)=12500;
fem_added(p4,1)=-450;
fem_added(p5,1)=12000;
ktotal=zeros(uru);
knew=zeros(uru);
First_row=rand(11,3);
Second_row=rand(11,3);
Third_row=rand(11,3);
CT=([]);
for ict=1:n
CT{ict}=[First_row(ict,:);Second_row(ict,:);Third_row(ict,:)];
end
T=([]);
for ti=1:1:n
T{ti}=blkdiag(CT{ti},CT{ti},CT{ti},CT{ti});
end
kg=([]);
K1 = repmat({zeros(12,1)},n,1);
K2 = repmat({zeros(12,1)},n,1);
K3 = repmat({zeros(12,1)},n,1);
K4 = repmat({zeros(12,1)},n,1);
K5 = repmat({zeros(12,1)},n,1);
K6 = repmat({zeros(12,1)},n,1);
K7 = repmat({zeros(12,1)},n,1);
K8 = repmat({zeros(12,1)},n,1);
K9 = repmat({zeros(12,1)},n,1);
K10 = repmat({zeros(12,1)},n,1);
K11 = repmat({zeros(12,1)},n,1);
K12 = repmat({zeros(12,1)},n,1);
K = repmat({zeros(12,1)},n,1);
fembar=([]);
for i=1:n
K1{i} = [SC1(i);0;0;0;0;0;-SC1(i);0;0;0;0;0];
K2{i} = [0;SC6(i);0;0;0;SC2(i);0;-SC6(i);0;0;0;SC2(i)];
K3{i} = [0;0;SC7(i);0;-SC3(i);0;0;0;-SC7(i);0;-SC3(i);0];
K4{i} = [0;0;0;SC4(i);0;0;0;0;0;-SC4(i);0;0];
K5{i} = [0;0;-SC3(i);0;(2*SC5(i));0;0;0;SC3(i);0;SC5(i);0];
K6{i} = [0;SC2(i);0;0;0;(2*SC8(i));0;-SC2(i);0;0;0;SC8(i)];
K7{i} = -K1{i};
K8{i} = -K2{i};
K9{i} = -K3{i};
K10{i} = -K4{i};
K11{i} = [0;0;-SC3(i);0;SC5(i);0;0;0;SC3(i);0;(2*SC5(i));0];
K12{i} = [0;SC2(i);0;0;0;SC8(i);0;SC2(i);0;0;0;(2*SC8(i))];
K{i} = [K1(i); K2(i); K3(i); K4(i); K5(i); K6(i); K7(i); K8(i); K9(i); K10(i); K11(i); K12(i)];
Ttr=T{i}';
kg(i)=Ttr*K{i}*T{i};
for p=1:12
for q=1:12
knew((L(i,p)),(L(i,q)))=kg(p,q);
end
end
ktotal=ktotal+knew;
fembar(i)=T{i}*fem_all(i);
end
kunr=zeros(uu);
for x=1:uu
for y=1:uu
kunr(x,y)=ktotal(x,y);
end
end
kuuInv=inv(kunr);
j1=(-1).*fem_added;
jlu=j1(1:uu,:);
delu=kuuInv*jlu;
dlr=size(ur1,2);
delr=zeros(dlr,1);
del=[delu;delr];
deli=zeros(12,1);
delbar=([]);
mbar=([]);
for i=1:n
for p=1:12
deli(p,1)=del((L(i,p)),1);
end
delbar(i)=deli(i);
mbar(i)=(kg(i)*delbar(i))+fembar(i);
end