フィルターのクリア

how to put a limited value for an input ?

3 ビュー (過去 30 日間)
mohamed
mohamed 2013 年 3 月 29 日
how to put a limited value for an input ? for example from (0 to 100) and if the user enter a value out of this range it will be invalid input ?

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 29 日
test=0
while test==0
a=input('enter 0<a<100')
if a>0 & a<100
test=1
end
end
  6 件のコメント
mohamed
mohamed 2013 年 3 月 29 日
this is right, but if i want to send him an error message when he entered the wrong data ?
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 29 日
add this
if or(min(a)<0, max(a)>100)
display('Error, all values of a should be between 0 and 100')

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNaNs についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by