how can i make a function file that will request the user if he will like to start the code execution? i would like to use inputs

1 Ansicht (letzte 30 Tage)
clc
clear all
%Assign variables to constants
V1=.3; V2=.3;
E1=200*10^9; E2=200*10^9;
d1=38; d2=70;
L=50;
F=450;
Z1=.025; Z2=.25; Z3=2.5;
%First Calculation for principal stress
b=sqrt((2*F)*((1-V1^2)/E1)+((1-V2^2)/E2)/((pi*L)*((1/d1)+(1/d2))));
Pmax=(2*F)/(pi*b*L);
%Second Calculation for principal stress
a1=Z3/b;
a2=sqrt(1+(Z3^2/b^2));
%Third calculation for principal stress
O1=(-2*V2*Pmax)*(a2-a1)
O2=(-Pmax)*(2-(1/(1+(Z3^2/b^2)))*(a2-(2*a1)))
O3=(-Pmax)/a2

Antworten (1)

Walter Roberson
Walter Roberson am 10 Dez. 2017
while true
...
if wants_to_quit()
break;
end
end
function should_quit = wants_to_quit
user_answer = = input('Do you want to continue? [Y] or N', 's');
should_quit = ismember(lower(user_answer), {'n', 'no'});

Kategorien

Mehr zu Stress and Strain finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by