How to have input function continue if enter key pressed
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I would like to have an input statement such as
response = input('Press enter to continue:','s')
and a while loop
while respond == '' end
This is not working exactly as planned. What is the best way to evaluate the return/enter key being pressed
0 comentarios
Respuesta aceptada
Walter Roberson
el 24 de Ag. de 2011
Do not compare a string to '' -- a string is an array of characters, so the comparison would fail if there are any characters in the string (because the length of the character array would not be the same as the length of '' )
You can use isequal() or strcmp(), but what you should really use here is isempty()
0 comentarios
Más respuestas (1)
Sean de Wolski
el 24 de Ag. de 2011
Could you use an inputdlg instead of input? It'll give you a few more options as far as keypressfcn/keyreleasefcn since it's a figure and you can control.
0 comentarios
Ver también
Categorías
Más información sobre Characters and Strings 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!