필터 지우기
필터 지우기

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

조회 수: 2 (최근 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

답변 (1개)

Walter Roberson
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'});

카테고리

Help CenterFile Exchange에서 Stress and Strain에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by