Finite Element Analysis in Matlab

2 views (last 30 days)
LUAN NGUYEN
LUAN NGUYEN on 3 Oct 2021
Commented: LUAN NGUYEN on 5 Oct 2021
E_steel=200*10^6; %kPa
L_deck=12; %m
%E=26; kips
E=115.654; %kN
%H=18; kips
H=80.068; %kN
for i=1:25
u(i)=i;
F(i)=0;
end
%Tower shaft AC:
A_AC=7.540*10^-3; %m^2
I_AC=5.438*10^-5; %m^4
%Tower shaft BC:
A_BD=1.814*10^-2; A_DC=A_BD; %m^2
I_BD=3.367*10^-4; I_DC=I_BD; %m^4
%Cables
A_cab=7.069*10^-4; %m^2
I_cab=0;
%Bridge deck
A_br=1.232*10^-2; %m^2
I_br=2.219*10^-4; %m^4
%Area
A(1)=A_AC;
A(2)=A_BD; A(3)=A(2);
A(4)=A_cab; A(5:7)=A(4);
A(8)=A_br; A(9:11)=A(8);
%Inertia
I(1)=I_AC;
I(2)=I_BD; I(3)=I(2);
I(4)=I_cab; I(5:7)=I(4);
I(8)=I_br; I(9:11)=I(8);
%Applied force vetor
F=F';
F(6)=-E;
F(9)=-E;
F(12)=-E;
F(14)=H;
%length
L_AC=sqrt(7.0^2+1.0^2); L(1)=L_AC;
L_BD=sqrt(1.0^2+0.5^2); L(2)=L_BD;
L_DC=sqrt(6.0^2+3.0^2); L(3)=L_DC;
L_CE=sqrt(6.0^2+6.0^2); L(4)=L_CE;
L_CF=sqrt(9.0^2+6.0^2); L(5)=L_CF;
L_CG=sqrt(12.0^2+6.0^2); L(6)=L_CG;
L_CH=sqrt(15.0^2+6.0^2); L(7)=L_CH;
L_DE=3; L(8)=L_DE;
L_EF=3; L(9)=L_EF;
L_FG=3; L(10)=L_FG;
L_GH=3; L(11)=L_GH;
%Theta
theta_AC=180-atand(7.0/1.0);
theta_BD=180-atand(7.0/3.5); theta_DC=theta_BD;
theta_DE=0; theta_EF=theta_DE; theta_FG=theta_DE; theta_GH=theta_DE;
theta_CE=360-atand(6.0/6.0);
theta_CF=360-atand(6.0/9.0);
theta_CG=360-atand(6.0/12.0);
theta_CH=360-atand(6.0/15.0);
theta(1)=theta_AC; theta(2)=theta_BD;
theta(3)=theta_DC; theta(4)=theta_CE;
theta(5)=theta_CF; theta(6)=theta_CG;
theta(7)=theta_CH; theta(8)=theta_DE;
theta(9)=theta_EF; theta(10)=theta_FG;
theta(11)=theta_GH;
%ID_array
ID_AC=[u(19) u(20) u(21) u(16) u(17) u(18)];
ID_CE=[u(16) u(17) u(18) u(5) u(6) u(7)];
ID_CF=[u(16) u(17) u(18) u(8) u(9) u(10)];
ID_CG=[u(16) u(17) u(18) u(11) u(12) u(13)];
ID_CH=[u(16) u(17) u(18) u(14) u(25) u(15)];
ID_DC=[u(1) u(2) u(3) u(16) u(17) u(18)];
ID_BD=[u(22) u(23) u(24) u(1) u(2) u(3)];
ID_DE=[u(1) u(2) u(4) u(5) u(6) u(7)];
ID_EF=[u(5) u(6) u(7) u(8) u(9) u(10)];
ID_FG=[u(8) u(9) u(10) u(11) u(12) u(13)];
ID_GH=[u(11) u(12) u(13) u(14) u(25) u(15)];
ID=[ID_AC; ID_BD; ID_DC; ID_CE; ID_CF; ID_CG; ID_CH; ID_DE; ID_EF; ID_FG; ID_GH];
kff=zeros(25,25);
kbeam=0;
%Element AC
for i=1:11
C=cosd(theta(i));
S=sind(theta(i));
kbeam(1)= E*A(i)/L(i)*C^2 + 12*E*I(i)/L(i)^3*S^2;
kbeam(2)=E*A(i)/L(i)*C*S - 12*E*I(i)/L(i)^3*C*S;
kbeam(3)=-6*E*I(i)/L(i)^2*S;
kbeam(4)=-E*A(i)/L(i)*C^2 - 12*E*I(i)/L(i)^3*S^2;
kbeam(5)=-E*A(i)/L(i)*C*S + 12*E*I(i)/L(i)^3*C*S;
kbeam(6)=-6*E*I(i)/L(i)^2*S;
kbeam(7)=E*A(i)/L(i)*S^2 + 12*E*I(i)/L(i)^3*C^2;
kbeam(8)=6*E*I(i)/L(i)^2*C;
kbeam(9)= -E*A(i)/L(i)*C*S + 12*E*I(i)/L(i)^3*C*S;
kbeam(10)=-E*A(i)/L(i)*S^2 - 12*E*I(i)/L(i)^3*C^2;
kbeam(11)=6*E*I(i)/L(i)^2*C;
kbeam(12)= 4*E*I(i)/L(i);
kbeam(13)=-kbeam(3);
kbeam(14)=-kbeam(8);
kbeam(15)=2*E*I(i)/L(i);
kbeam(16)=kbeam(1);
kbeam(17)=kbeam(2);
kbeam(18)=-kbeam(3);
kbeam(19)=-kbeam(10);
kbeam(20)=-kbeam(8);
kbeam(21)=kbeam(12);
kele(1:6,1)=kbeam(1:6);
kele(2:6,2)=kbeam(7:11);
kele(3:6,3)=kbeam(12:15);
kele(4:6,4)=kbeam(16:18);
kele(5:6,5)=kbeam(19:20);
kele(6,6)=kbeam(21);
kele= triu(kele.',1) + tril(kele);
array=ID(i,:);
for n=1:6
for m=1:6
kff(array(n),array(m))= kff(array(n),array(m))+kele(n,m);
end
end
end
kff;
F;
xf=kff\F;
I have the errors at line 8 and line 9. How to fix them ? . Thanks

Answers (1)

KSSV
KSSV on 4 Oct 2021
It is not an error, it is a warning. You need to initialize the variables which you are using in loop.
Replace the lines:
for i=1:25
u(i)=i;
F(i)=0;
end
with
u = 1:25 ;
F = zeros(size(u)) ;
If you want to use a loop, which is not required:
u = zeros(1,25) ;
F = zeros(1,25) ;
for i=1:25
u(i)=i;
F(i)=0;
end

Categories

Find more on Programming Utilities in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!