any function like kbhit
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
gang gyoo jin
el 24 de Jun. de 2016
Editada: armando herculano
el 1 de Abr. de 2024
Hi all Is there any function like kbhit(in C) in matlab. I want to use that function inside the for loop to terminate the loop. Thanks in advance
for i=1:100000
if kbhit == 'q'
break;
end
end
0 comentarios
Respuesta aceptada
Walter Roberson
el 24 de Jun. de 2016
1 comentario
Andrew Diamond
el 8 de Dic. de 2018
kbhit oesn't seem to work in Matlab 2017b. I get this error message:
Error using set
The name 'Userdata' is not an accessible property for an instance of class
'com.mathworks.mde.cmdwin.CmdWin'.
That occurs in the init, i.e. kbhit('init') in:
set(KBHIT_h_cw, 'userdata', []);
I don't see a property method/accessor for "userdata"
Más respuestas (3)
Bin Yang
el 21 de Nov. de 2019
Replace your kbhit.m with the one attached here, it should work. The original version tried to store key event data in the 'Userdata' property of the command window object, however it is no longer viable in later Matlab versions. What I did was just to asign key event data directly to a global variable.
0 comentarios
armando herculano
el 1 de Abr. de 2024
Editada: armando herculano
el 1 de Abr. de 2024
for MATLAB:
while true
ch = getkey
if ch != 165 break; end
end
----------------------
for OCTAVE
while true
if kbhit(1) break; end
end
-----------------------------
while true
% 165 ASCII code for null
if kbhit(1) != 165 break end
end
--------------------------------------
0 comentarios
Ver también
Categorías
Más información sobre Calculus 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!