Record timing of user input

7 Ansichten (letzte 30 Tage)
David am 20 Jan. 2014
Beantwortet: David am 20 Jan. 2014
Hello and thank you for reading my question,
I'm trying to display images and record the timing (and keyboard value if possible) of when the user advanced to the next image. (that is, the user presses a keyboard button after they are done with the image and advances to the next image).
I've looked at some of the "input" and such commands but i'm still confused on this.
any ideas how to do this?
thankyou, veritas

Akzeptierte Antwort

Kye Taylor
Kye Taylor am 20 Jan. 2014
I think you want tic and toc, as in the example below:
% I will create a cell that represents some collection of images
nImg = 4;
timings = zeros(1,nImg);
I = cell(1,nImg); % cell of images
for i = 1:nImg
I{i} = rand(640,480,3); % I{i} is an 640-by-480-by-3 random RGB image
for i = 1:nImg
tic % start stopwatch
input('Hit any key to advance to next image.');
timings(i) = toc; % end stopwatch and store result in element i

Weitere Antworten (2)

Bruno Pop-Stefanov
Bruno Pop-Stefanov am 20 Jan. 2014
Bearbeitet: Bruno Pop-Stefanov am 20 Jan. 2014
You can use tic to start a stopwatch and toc to read the elapsed time.
As for the user input, it depends on how you are planning your human-computer interface. The input function requests a user input in the Command Window using the keyboard. For example:
number = input('Choose a number\n');
However, you can also get user input through a mouse click on the image you are displaying (see ginput) or you can design more complex graphical user interfaces using the GUI Design Environment (GUIDE).
If you want to measure how long the user looked at a picture before displaying the next image, you could write a script in which the images are displayed one after the other, but using tic and toc between each image to measure time and using ginput(1) to wait for a mouse click.

David am 20 Jan. 2014
wow that was very fast. thank you guys very much!!! this worked immediately.


Mehr zu Desktop finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by