How can I show the error message when the input data get wrong?
Mostrar comentarios más antiguos
I want to create the inputdlg to let user to input the data. But how can I add the check coding to check the input is between 2000 and 2019? Thank you.
My current coding:
prompt = {'Start Year:','End Year:'};
dlgtitle = 'Year Range (Between 2000 and 2019)';
dims = [1 50];
answer = inputdlg(prompt,dlgtitle,dims);
disp(answer)
Respuesta aceptada
Más respuestas (1)
KSSV
el 11 de Dic. de 2022
prompt = {'Start Year:','End Year:'};
dlgtitle = 'Year Range (Between 2000 and 2019)';
dims = [1 50];
answer = inputdlg(prompt,dlgtitle,dims);
while any(str2double(answer)<2019) || any(str2double(answer) > 2020)
answer = inputdlg(prompt,dlgtitle,dims);
end
disp(answer)
1 comentario
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!