I don't know why the function won't run.
Show older comments
clear all;
clc;
function n = CourseProject(d);
datas = textread('Stress_History.txt');
astress = datas(:,2); % axial stress
sstress = datas(:,3); % shear stress
Sut = 720; % Ultimate strength
Sy = 400; % yield stress
Vp = 0.3; %Poisson's Rati0
MoE = 206; %Modulus of Elasticity
roe = 7861; %Density
L = 100; %Length
NC = 0.062; %Neuber Constant
Seprime = 0.87 * Sut; % Endurance limit
Snom = 430; %Nominal Stress
Tnom = 400; %Nominal Shear
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; % Maximize the safety factor
end
The file is saved as CourseProject.m
Answers (1)
Walter Roberson
on 8 May 2018
1 vote
Remove the first two lines. The first executable line should be the function statement.
Categories
Find more on Stress and Strain in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!