How do I use the if else function in a traffic model? -

percent=input('What is the fill ratio? ');
for percent = input('What is the fill ratio? ')
if input >1
disp('Please enter a value between 0 and 1, exclusive')
elseif input <0
disp('Please enter a value between 0 and 1, exclusive')
end
end

답변 (1개)

Star Strider
Star Strider 2019년 3월 1일
I would do something like this:
percent = 2;
while (percent < 0) || (percent > 1)
percent=input('What is the fill ratio? ');
fprintf('Fill ratio = %g\n\n', percent)
if (percent < 0) || (percent > 1)
disp('Please enter a value between 0 and 1, exclusive')
fprintf('\n\n')
end
end

카테고리

도움말 센터File Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

태그

질문:

2019년 3월 1일

답변:

2019년 3월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by