clear all;
clc;
function n = CourseProject(d);
datas = textread('Stress_History.txt');
astress = datas(:,2);
sstress = datas(:,3);
Sut = 720;
Sy = 400;
Vp = 0.3;
MoE = 206;
roe = 7861;
L = 100;
NC = 0.062;
Seprime = 0.87 * Sut;
Snom = 430;
Tnom = 400;
Asmin = min(astress);
Asmax = max(astress);
SSmin = min(sstress);
SSmax = max(sstress);
At = 0.25*pi*(d^2);
Bendinga = 0.246 - (3.08*(10^-3)*Sut) + (1.51*(10^-5)*(Sut^2)) - (2.67*(10^-8)*(Sut^3))
Torsiona = 0.190 - (2.51*(10^-3)*Sut) + (1.35*(10^-5)*(Sut^2)) - (2.67*(10^-8)*(Sut^3))
Kf = Asmax/Snom;
Kfs = SSmax/Tnom;
Mba = ((Asmax+Asmin)*L)/2;
Mbm = ((Asmax-Asmin)*L)/2;
Ta = (SSmax+SSmin)/2;
Tm = (SSmax-SSmin)/2;
sigmaa = (32*Mba)/(pi*d^3);
sigmam = (32*Mba)/(pi*d^3);
sigprimea = sqrt((sigmaa*Kf)^2 + 3*(Ta*Kfs)^2);
sigprimem = sqrt((sigmam*Kf)^2 + 3*(Tm*Kfs)^2);
if d<= 51
kb = 1.24*(d^-0.0107);
Se = kb*Seprime;
end
if d<51
kb = 1.51*(d^-0.157);
Se = kb * Seprime;
end
n =1/((sigprimea/Se) + (sigprimem/Sut));
n = -n;
end