# Lateral-Torsional Buckling of Cantilever Steel Beams under 2 Types of Complex Loads
## Appendix A Sample Coding of MATLAB
\(betaba=(1/(2*l_{\rm x})*(-(h+t_{2}/2-d1)*((1/12)*b_{1}^{\circ}3*t_{1}+b_{1}*t_ {1}*(h+t_{2}/2-d1)^{\circ}2)+(d1-t_{2}/2)*((1/12)*b_{2}^{\circ}3*t_{2}+b_{2}*t 2*(d1-t_{2}/2^{\circ}2)+0.25*t_{w}*((d1-t_{2}/2-d_{2}/2)^{\circ}4-((h+t_{2}/2- d1)-t_{1}/2)^{\circ}4))-(-(h+t_{1}/2+t_{2}/2-d1-t_{1}/2-(1/12)*b_{2}^{\circ}3*t_{2}*h/((1/12) *b_{1}^{\circ}3*t_{1})))/h\);%the ratio of [PERSON]'s coefficient to h, i.e., \(\beta_{\rm x}\) in Equation (13)  
\(K=\) sqrt(pi'2*e*l_{\rm w}/(G*l_{\rm x}*length^{\circ}2));%torsional stiffness coefficient  
\(apba=ap/h\); %i.e., \(\alpha_{\rm y}^{\circ}\) in Equation (13)  
\(aqba=aq/h\); %i.e., \(a_{q_{y}}^{\circ}\) in Equation (13)  
\(R^{0}=\) zeros(\(N\),\(N\));  
for \(m=1\):\(N\)  
for \(r=1\):\(N\)  
for \(m=1\):\(N\)  
for \(r=1\):\(N\)  
if \(m=-r\)  
\(Q^{0}(m\),\(r)=(-1+2*m)^{\circ}4*pi^{\circ}4*yita/(32*(1+yita)^{\circ}2)+(-1+2*m)^{ \circ}2*pi^{\circ}4*yita/(8*K^{\circ}2*(1+yita)^{\circ}2)\);  
end  
end  
end  
end  
end  
end  
end  
end  
end  
end  
end  
end  
end  
end  
end  
end  
end  
end
end  
end
end  
\(R^{1}=\) zeros(\(N\),\(N\));  
\(S^{1}=\) zeros(\(N\),\(N\));  
for \(m=1\):\(N\)  
for \(r=1\):\(N\)  
if \(m=\)\(r\)  
\(SS1=-\)pi*(\(-\)96*aerfa*cos(\(m\)*pi) + (\(-\)1 + 2*\(m\))*pi*(\(-\)42*(1 + aerfa) + (1-2*\(m\))*pi^2*  
(aerfa + 3*\(namuda\)^2) + 48*cos(0.5*(\(-\)1 + 2*\(m\))*pi*namuda)\(-\)6*cos((\(-\)1 + 2*\(m\))*pi*namuda)))  
/(24*(\(-\)1 + 2*\(m\))*(aerfa + 2*\(namuda\)));  
\(SS2=0\);  
\(\text{S}^{1}(m\),\(r)=\text{SS1}+\text{SS2}\);  
else  
\(\text{SS1}=-\)pi*(\(-\)16*aerfa*(\(r-m\))^2*(\(-\)1+r+\(m\))^2*cos(pi*\(m\)) + pi*(\(-\)1 + 2*\(m\))*(\(-\)((1-2*\(r\)))^2  
*(\(-\)1 + 2*\((-\)1 + \(r\))*\(r\)-6*(\(-\)1 + \(m\))*\(m\))*(\(1+aerfa) + 8*\((r-m)^2*(-\)(1 + \(r+m\))^2*cos(0.5*pi*  
(\(1-\)2*\(m\))*\(namuda)\) + (1-2*\(m\))^2*(\(-\)(\(-\)1 + \(r+m\))^2*cos(pi*(\(r-m\))*namuda) - (\(r-m\))^2*cos(pi*(\(-\)1 + \(r+m\))*\(namuda))))/(4*(-\(r+m\))^2*(\(-\)1 + \(r+m\))^2*(\(-\)1 + 2*\(m\))*(aerfa + 2*\(namuda)));  
\(\text{SS2}=0\);  
\(\text{S}^{1}(m\),\(r)=\text{SS1}+\text{SS2}\);  
end  
end  
\(\text{T}^{1}=\) zeros(\(N\),\(N\));  
for \(m=1\):\(N\)  
for \(r=1\):\(N\)  
\(\text{T}^{1}(m\),\(r)=\text{S}1(r\),\(m\));  
end  
\(\text{Q}^{1}=\) zeros(\(N\),\(N\));  
for \(m=1\):\(N\)  
for \(r=1\):\(N\)  
if \(m=\)\(r\)  
QQ1 = betaba*pi^2*((1-2*m)^2*pi^2*(aerfa + 3*\(namuda\)^2)\(-\)6*(1 + aerfa) + 6*cos((\(-\)1 + 2*\(m\))*pi*namuda))/(1*(aerfa + 2*\(namuda\)));  
QQ2 = _abba*pi*aerfa*(3*pi^2-6*m+pi^-8*cos(m+pi))/((-1 + 2*\(m\))*(aerfa + 2*\(namuda\)))_-2  
* cos(0.5*(2*\(m-1\))*pi*namuda))^2/(aerfa + 2*\(namuda\));  
Q\({}^{1}(m\),\(r)=\text{QQ1}+\text{QQ2}\);  
else  
QQ1 = 2*(-1 + 2*\(r\))*(\(-\)1 + 2*\(m\))*betaba*pi^2*((-1 + 2*\(r\))*(-1 + 2*\(m\))*(1 + aerfa) - (\(-\)1 + \(r+m\))^2*cos(pi*(\(-\)\(m\))+namuda) + (\(-\)\(r+m\))^2*cos(pi*(\(-\)1 + \(r+m\))*\(namuda))/(4*(r - \(m\))^2*(-1 + \(r+m\))^2*(aerfa + 2*\(namuda\)));  
QQ2 = _-2*alpha*aerfa*pi^2*(2-4*cos(pi*\(r\))/(pi*(1-2*\(r\)))-4*cos(pi*\(m\))/(pi*(1-2* \(m\))))/(2*(aerfa + 2*\(namuda))-2*alpha*pi^2*(1 - cos(0.5*(2*\(m-1\))*pi*namuda))*(1 - cos(0.5*(2*\(r-1\)) *pi*namuda))/(aerfa + 2*\(namuda\));_  
Q\({}^{1}(m\),\(r)=\text{QQ1}+\text{QQ2}\);  
end  
\(D_{0}=[R^{0}\),\(S^{0}\);\(T^{0}\),\(Q^{0}\)];%Equation (35) in the paper  
\(D_{1}=[R^{1}\),\(S^{1}\);\(T^{1}\),\(Q^{1}\)];%Equation (36) in the paper  
\([V\),\(D]=\text{eig}(D_{0}\), \(D_{1})\);%\(D\) is the diagonal matrix composed of generalized eigenvalues,  
and \(V\) is the corresponding eigenvector  
\(D=\text{eig}(D_{0}\), \(D_{1})\);  
\(L=0\);  
for \(i=1\):\(2*N\)if isreal(\(D(i)\)) = =1 && \(D(i)>0\)  
\(L\) = \(L+1\);  
Eg(\(L\)) = \(D(i)\);  
end  
\(P1\) = min(\(Eg\));  
[row,column] = find(\(D\) == \(P1\));  
\(A_{n}\) = V(1:10,row),%Vector composed of generalized coordinates of the lateral deflection function \(u\)(z)  
\(B_{n}\) = V(\(N+1\):\(N+10\),row),%Vector composed of generalized coordinates of the twist angle function \(\varphi\)(z)  
\(M_{\rm cr}\) = \(P1\)*pi^2*\(h\)*\(E\)*\(I_{y}\)/(length*2),% \(M_{\rm cr}\) is the critical moment