Can waitforbuttonpress function be used with switch cases..?

2 vues (au cours des 30 derniers jours)
Nipjyoti Sarma
Nipjyoti Sarma le 21 Oct 2016
Commenté : Nipjyoti Sarma le 21 Oct 2016
I have used this piece of Code but it's not working. Can you help me where I am wrong here.. for i=1:10 keydown = waitforbuttonpress; switch keydown case'0' disp(5); case'1' disp(6); end end Thank you.

Réponse acceptée

Massimo Zanetti
Massimo Zanetti le 21 Oct 2016
Output of waitfrobuttonpress is not a string, is number:
for i=1:10
keydown = waitforbuttonpress;
switch keydown
case 0
disp(5);
case 1
disp(6);
end
end

Plus de réponses (0)

Catégories

En savoir plus sur Timing and presenting 2D and 3D stimuli dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by