How can I ask the user to input units of either m or in, then have the program keep asking them for units until they input either m or in?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Tanner Larkey
el 13 de Abr. de 2018
Comentada: Tanner Larkey
el 14 de Abr. de 2018
Asks the user the unit of l. The program must accept the following units or keep asking for a unit: a. m b. in
1 comentario
bidyut mandi
el 13 de Abr. de 2018
Editada: bidyut mandi
el 13 de Abr. de 2018
Ask the user the unit of I means disp('Enter the unit of I').I don't get that the program everytime ask the unit of a.m,b.in or single time.Please clarify this
Respuesta aceptada
Walter Roberson
el 14 de Abr. de 2018
I suggest you use
iChoice = menu('Select a unit', 'inches', 'metres');
This will return 1 for inches and 2 for metres.
1 comentario
Más respuestas (1)
ES
el 13 de Abr. de 2018
disp('Choose the Unit.');
disp('[0] Inches.');
disp('[1] Metres.');
iChoice=input('Please make a choice. ');
while(~isnumeric(iChoice) ||(uint8(iChoice)>1))
iChoice=input('Please make a valid choice. Enter 0 to quit. ');
end
Ver también
Categorías
Más información sobre NaNs en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!