MATLAB APP DESIGNER INPUT EDIT FIELD. PLEASE HELP!!

9 vues (au cours des 30 derniers jours)
hgrlk
hgrlk le 22 Mai 2021
Commenté : hgrlk le 28 Mai 2021
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

Réponse acceptée

Michael Van de Graaff
Michael Van de Graaff le 22 Mai 2021
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

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by