any function like kbhit
조회 수: 18 (최근 30일)
이전 댓글 표시
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
채택된 답변
Walter Roberson
2016년 6월 24일
댓글 수: 1
Andrew Diamond
2018년 12월 8일
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"
추가 답변 (3개)
Bin Yang
2019년 11월 21일
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
armando herculano
2024년 4월 1일
편집: armando herculano
2024년 4월 1일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!