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?

 Risposta accettata

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

Più risposte (0)

Categorie

Scopri di più su External Language Interfaces in Centro assistenza e File Exchange

Prodotti

Release

R2007a

Community Treasure Hunt

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

Start Hunting!

Translated by