MATLAB APP DESIGNER INPUT EDIT FIELD. PLEASE HELP!!

8 visualizaciones (últimos 30 días)
hgrlk
hgrlk el 22 de Mayo de 2021
Comentada: hgrlk el 28 de Mayo de 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

Respuesta aceptada

Michael Van de Graaff
Michael Van de Graaff el 22 de Mayo de 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

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by