How do I prompt user to re-input value if first attempt is incorrect?
12 ビュー (過去 30 日間)
古いコメントを表示
Lauren-Xante Claassen
2023 年 7 月 19 日
コメント済み: Lauren-Xante Claassen
2023 年 7 月 19 日
I am trying to prompt user to input a value for R^2, accepting or rejecting value within a range 0-1. If value is correct, proceed to next input question. If value is incorrect, display error message to user and re-prompt them to insert new value within range. Currently, I get the error but it does not allow me to re-enter a new value for that variable, it simply continues to next prompt. I need to create a loop of some kind but am not sure how?
prompt = inputdlg('Please enter an R^2 value for Cement:');
data = str2double(prompt);
if 0<= data && 1>=data
else
errordlg('Input must be between the values 0-1.');
end
prompt = inputdlg('Please enter an R^2 value for Blast Furnace:');
data = str2double(prompt);
if 0<= data && 1>=data
else
errordlg('Input must be between the values 0-1.');
return
end
0 件のコメント
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!