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 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Walter Roberson
2017-12-10
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'});
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Stress and Strain 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!