MATLAB APP DESIGNER INPUT EDIT FIELD. PLEASE HELP!!

8 ビュー (過去 30 日間)
hgrlk
hgrlk 2021 年 5 月 22 日
コメント済み: hgrlk 2021 年 5 月 28 日
HELLO,
I have a problem with matlab app designer. I'm trying to do something, when I give input into "age", if it is not between the range, a warning message appears. But I want to do this as a loop. I mean, if I give wrong input, app shows me an warning message, and then I must rewrite new value. But my code doesnt control again my value. I cannot find the code about give new input to Edit Field number.
If you can help me I will be very glad. Thank you!
% Value changed function: ageoffirstpilotEditField
function ageoffirstpilotEditFieldValueChanged(app, event)
value_age = app.ageoffirstpilotEditField.Value;
flag1 = false;
while flag1 == false;
if app.ageoffirstpilotEditField.Value < 25 || app.ageoffirstpilotEditField.Value > 60
f = warndlg('The range of pilot age should be between [25,60]. Try again!','Invalid Input');
app.KparameteroffirstpilotEditField.Value = 0;
%%%%
else
break
end
end
end

採用された回答

Michael Van de Graaff
Michael Van de Graaff 2021 年 5 月 22 日
Does something like this do what you want?
function ageoffirstpilotEditFieldValueChanged(app, event)
goodage = 0;
while goodage==0
value = app.ageoffirstpilotEditField.Value;
if value< 25 || value>60
goodage = 0;
prompt = 'enter age 25<= age<= 60';
title = 'Age out of range';
dims = 1;
defaultage = {'40'};
answer = inputdlg(prompt, title,dims,defaultage);
app.ageoffirstpilotEditField.Value = str2num(answer{1});
elseif value> 25 && value<60
goodage = 1;
end
end
disp('success')
end
  1 件のコメント
hgrlk
hgrlk 2021 年 5 月 28 日
Yes thanks for help! :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by