How to capture time interval between two keypress.
Afficher commentaires plus anciens
I want to capture time between two keypress .Time when one key is released and next key is pressed.I made code using cputime.Its like
function Keyrelease_Test
h = figure;
set(h,'KeyReleaseFcn',@KeyUpCb,'KeyPressFcn',@KeyDownCb)
StartTime=0;
function KeyUpCb(~,~)
StartTime=cputime;
end
function KeyDownCb(~,~)
Time=cputime-StartTime;
disp(Time)
end
end
but when i press 3 key it gives output like: >> Keyrelease_Test 54.8968
0.1872
0
0.0156
but for 3 keypress it must give 2 time.please help me
i have also made code using now
function Keyrelease_Set
h = figure;
set(h,'KeyReleaseFcn',@KeyUpCb,'KeyPressFcn',@KeyDownCb)
t1=0;
t2=0;
function KeyUpCb(~,~)
t1=rem(now,1);
end
function KeyDownCb(~,~)
t2=rem(now,2);
Time=t2-t1;
disp(Time)
end
end
for 2 keypress it gives output like
Keyrelease_Set
0.8938
1.6852e-05
please help me with this code or i have to use any other function or logic??
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!