MATLAB Answers


18 views (last 30 days)
a) how do create a stroop test to randomise the colour of the word. e.g. the word 'RED' with a blue/green/white font colour
b) i am also interested in randomising the colour of a square
i have the codes to display the word and the 2 squares below it but how do i get it to run with varying colours throughout the experiment in a randomised order?
any help would be much appreciated and many thanks in advance


Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 6 Dec 2019
Edited: Adam Danz on 6 Dec 2019
The handle to the text object and the handle to the "square" (not sure what you mean here, it could be a rectangle object, a patch object, an axes, who knows...) both have properties that allow you to edit their colors. But the property names vary between different sets of objects. Since we don't know what kind of objects you're working with, we can only be as specific as the content offered in your question (which isn't specific).
The two most common property names that changes an object's color are
  • Color
  • FaceColor
This demo below shows you how to change the "Color" property. The "FaceColor" property of other objects works in the same way.
h = text(. . .);
h.Color = 'r';
% -or-
h.Color = [1 0 0];
% -or-
set(h, 'Color', [1 0 0])


Show 6 older comments
Adam Danz
Adam Danz on 7 Dec 2019
Look at the example more closely.
b = conditions.Color(2:45,:);
Tanitoluwa Femi-Idowu
Tanitoluwa Femi-Idowu on 7 Dec 2019
thanks for the help, its been fixed now i did b = conditions.Color(1:45,:); and all the 45 colour codes were put into b
I am also trying to create a loop for presenting the stroop words
  • i know that A(word) and B(colour) now have a randomised order. i am now trying to incorproate that into a for loop.
How do i do this,
i went on the cogent website and this is the xample they gave for a stroop loop but i dont understand it, can you please help me explain what it means?
Adam Danz
Adam Danz on 9 Dec 2019
Here's a general template to show how to set up a loop. I don't know what loop you want to make but you can follow this plan:
for i = 1:size(conditions ,1)
% access the i_th condition
About the content on the cogent website, there are comments on each line of the code that tells you what the lines are doing. If you have a question about a specific line and cannot understand the help() and doc() literature, tell me which line to help you out with.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by