MATLAB Examples

Take the Stroop Test



The test along with its experimental results is described in:

Stroop, John Ridley (1935). "Studies of interference in serial verbal reactions". Journal of Experimental Psychology 18 (6): 643–662.


help StroopTest
  Produce a figure to take the Stroop test.
      A figure is produced which contains words in #prob_size# rows which
      are known color names, and are shown in a colored font. To take the
      Stroop test, quickly identify the color of each of these words (don’t
      read them). Say the colors out loud. Try to be as accurate as you
      can, and finish the test as quickly as you can. This task, called the
      Stroop Test, is much more challenging than it first appears. It’s
      much harder to identify a color when it is different from the word
      (#SHUFFLE#=1) than it is to identify when the two match
      (#SHUFFLE#=0). This challenging test relies on two key cognitive
      skills, response inhibition and selective attention. Doing the test
      for #SHUFFLE#=1 results in considerably more time than it would take
      for #SHUFFLE#=0.
  Required input arguments
      #words# (column vector) contains the color names as strings, one
      string per row. all of the vertically concatenated strings must have
      the same length.
      #colors# ([size(#words#,1) x 3]) contains the color denoted by each
      string in #words# in rgb representation. Look for ColorSpec (Color
      Specification) in the MATLAB documentation
      #SHUFFLE# (binary) determined if the colors in the figure are to be
      shuffled, so that the Stroop Test can begin. If #SHUFFLE#=0 no
      shuffling occurs and in the figure produced the various color names
      appear with the respective color.
      #prob_size# (integer) is the size of the problem, i.e. the number of
      the rows of words in the final figure.
      #FigID# (integer) is the number of the label of the figure to be
  Output parameters
  Copyright (c) 13-May-2014
      George Papazafeiropoulos
      First Lieutenant, Infrastructure Engineer, Hellenic Air Force
      Civil Engineer, M.Sc., Ph.D. candidate, NTUA

Brief history of the Stroop Test

In 1935, a farmer’s son named John Ridley Stroop became the first to publish in English on the current version of this cognitive task. Developed as part of his dissertation at George Peabody College, his task became the basis for the Stroop Test, which remains a widely used neuropsychological assessment to this day.

How your brain processes the Stroop Test

Because most people’s automatic response is to read a word, the Stroop Test is a classic test of response inhibition. This skill involves responding quickly while avoiding incorrect impulses that may interfere with accomplishing goal-driven tasks. Response inhibition is associated with the brain’s executive function, and brain imaging studies have found that performing the Stroop Test activates brain areas involved in executive function, such as the dorsolateral prefrontal cortex. In fact, individuals with ADHD and depression, whose poor executive function makes them struggle to pay attention and control reactions, often have a harder time performing the Stroop Test. The Stroop Test also challenges selective attention, or the ability to choose which stimuli to focus on and which to ignore. The mental flexibility required to switch between multiple stimuli is essential: without good selective attention, it can also be easy to make errors.

Initial definitions

In the subsequent code the following initial definitions are made (in the order presented below):

  1. Set the column vector containing the color names
  2. Set the column vector containing the color denoted by each string in the previous vector in rgb representation
  3. Set SHUFFLE parameter so that colors are not shuffled
  4. Set SHUFFLE parameter so that colors are shuffled
  5. Set the problem size for a small problem (5 rows)
  6. Set the problem size for a large problem (15 rows)
words=['YELLOW ';'MAGENTA';'CYAN   ';'RED    ';'GREEN  ';'BLUE   ';'BLACK  ']; %1
colors=[1 1 0;1 0 1;0 1 1;1 0 0;0 1 0;0 0 1;0 0 0]; %2
SHUFFLE1=0; %3
SHUFFLE2=1; %4
prob_size1=5; %5
prob_size2=15; %6


  1. Produce Figure 1 (small problem with matching colors)
  2. Produce Figure 2 (large problem with matching colors)
  3. Produce Figure 3 (small problem with non-matching colors)
  4. Produce Figure 4 (large problem with non-matching colors)


Copyright (c) 13-May-2014 by George Papazafeiropoulos