using break and continue to using true extend ?

조회 수: 2 (최근 30일)
Ugur Sahin
Ugur Sahin 2020년 2월 15일
댓글: Walter Roberson 2020년 2월 16일
Hi guys,
I am trying to get input in the true interval such as that if m value interval 0<m<20 continue to process(jump to next row), but m>20 break the process with error message. How can ı do that with while or for and continue, break functions can anyone help me ?
Mass = input('please enter the mass');
while 0<Mass || Mass<20
continue
end
while Mass>20
break
fprintf('the wrong extend of value');
end
I have tried that but doesn't process. Could you help me ?
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 2월 16일
What should happen for m <= 0 ? It should not continue to process, but it should also not generate an error message ?

댓글을 달려면 로그인하십시오.

채택된 답변

Sindar
Sindar 2020년 2월 16일
It sounds like you want to check the conditions with if statements inside your while loop:
while true
% do stuff
Mass = input('please enter the mass');
if Mass > 20
break
fprintf('the wrong extend of value');
end
% already checked Mass > 20
if Mass > 0
continue
end
% do stuff if Mass <=0
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by