How to get input from user without asking to press enter?

How to get input from user without asking to press enter at MATLAB prompt?

 Réponse acceptée

The ability to take input from user without asking to press enter is not directly available through any of the features in any of the MATLAB releases.
As a possible workaround, WAITFORBUTTONPRESS and 'CurrentCharacter' can be used. Following is an illustrative example:
w = waitforbuttonpress;
if w
p = get(gcf, 'CurrentCharacter');
disp(p) %displays the character that was pressed
disp(double(p)) %displays the ascii value of the character that was pressed
end

Plus de réponses (0)

Catégories

En savoir plus sur External Language Interfaces dans Centre d'aide et File Exchange

Produits

Version

R2007a

Community Treasure Hunt

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

Start Hunting!

Translated by