4 views (last 30 days)
Barbara Fiorani
Barbara Fiorani on 28 Oct 2020
Edited: Walter Roberson on 28 Oct 2020
I need to assign colours to Kb names as I am creating a stroop task script with Psychtoolbox.
This is a part of my script:
WordList = {'blanket', 'garage', 'shampoo', 'handle', 'sofa', 'curtain', 'switch', 'bathroom', 'vase', 'hallway', 'duster', 'lounge'};
rgbColors = [1 0 0; 0 1 0; 0 0 1];
%Improve portability of the code acorss operating systems
% Specify key names of interest
activeKeys = [KbName('LeftArrow') KbName('RightArrow') KbName('UpArrow') KbName('Space')];
% Restrict the keys for keyboard input to the keys we want
% Suppress echo to the command line for keypresses
%Assign Kb to colours ??????????
How can i pair the Kb with colours? For example, if it appear a word in yellow the participant has to press Kb 'Uparrow' and so forth.

Answers (1)

Walter Roberson
Walter Roberson on 28 Oct 2020
Edited: Walter Roberson on 28 Oct 2020
You appear to be using the third party toolbox http://psychtoolbox.org/docs/RestrictKeysForKbCheck .
The code you show here does not display any text.
The code to display text in colour is specific to the toolbox, not part of MATLAB.
You would be responsible for keeping track of which color you assign with particular text, and for waiting for key presses and doing whatever is appropriate in your code when the "right" or "wrong" key press is found.
Really you are asking about Psychtoolbox, not about MATLAB. Psychtoolbox has its own forum, http://psychtoolbox.org/forum.html
I would suggest to you that in the future when you are working with a third-party toolbox, that you familiarize yourself with the resources / support facilities for the toolbox before you reach an "urgent" deadline.


Community Treasure Hunt

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

Start Hunting!

Translated by