How to reset typing in loop input if is Negative?

조회 수: 1 (최근 30일)
Emilia
Emilia 2020년 12월 13일
답변: Walter Roberson 2020년 12월 13일
Hello,
I want to make a typo refund if there is a user error with negative. For example if a user types negative then the output will return the same as original.
Thanks for the helpers
clc;
clear;
v=input('Insert poisson ratio:'); %Poisson's ratio
if isempty(v) || (v<=0)
end

채택된 답변

Walter Roberson
Walter Roberson 2020년 12월 13일
while true
v = input('Insert poisson ratio: '); %Poisson's ratio
if isnumeric(v) && isscalar(v) && v >= 0
break
end
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