# Randomise stimuli display on screen Psychtoolbox

**URL:** <https://psychtoolbox.discourse.group/t/randomise-stimuli-display-on-screen-psychtoolbox/1931>\
**Category:** Uncategorized\
**Created:** [March 17, 2016, 9:51am UTC](https://psychtoolbox.discourse.group/t/randomise-stimuli-display-on-screen-psychtoolbox/1931 "2016-03-17T09:51:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [March 17, 2016, 9:51am UTC](https://psychtoolbox.discourse.group/t/randomise-stimuli-display-on-screen-psychtoolbox/1931/1 "2016-03-17T09:51:57Z")

</div>

I'm trying to set up an experimental script.

One of the response collected are correct or incorrect responses to math equations.

I would like to generate simple addition, multiplication, division math equations with predefined answers and these answers will either be correct or incorrect, to be judged by the participant.

3 equations will appear at once on screen then be judged one by one if it's correct or incorrect

for example:&nbsp;

3+5 =8&nbsp;

4+9=12&nbsp;

1+3=4

At the moment, I've created the cell:&nbsp;

EasyCorrect = {'3+4=7', '2+12=14', '4+4=8', '5+7=12', '7+8=15', '15-4=11', '18-11=7', '15-5=10', '16-8=8', '13-9=4'};

msize = numel (EasyCorrect)

Easy\_Correct = EsayCorrectrandperm(msize, 1))

These commands would randomly select one equation from the EasyCorrect array.&nbsp;

The problem now is:&nbsp;

1. how do I display this on screen?

2. how do I display all three sets of equations at the same time?&nbsp;

Presumable, a function such as this:&nbsp;

DrawFormattedText(mainwin, char(Easy\_Correct), 'Center', 'Center')

But it doesn't work...!!

Any help would be much appreciated

---

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [March 17, 2016, 12:58pm UTC](https://psychtoolbox.discourse.group/t/randomise-stimuli-display-on-screen-psychtoolbox/1931/2 "2016-03-17T12:58:56Z")

</div>

Judging by your example, the first thing you'll have to do is index the Easy\_Correct cell array to select out one of the strings representing the equations, e.g.   
  
DrawFormattedText(mainwin, (Easy\_Correct{1}, 'Center', 'Center')  
  
 Also, are you calling Screen('Flip') after calling DrawFormattedText? Screen('Flip') is the function that actually updates the display.  
  
 Sorry if I'm telling you something you already know, but it would be helpful if you included a more of a reproducible example of the code you are running, so people don't have to assume what you are/are not doing.   
  
 - Will   
  

On 3/17/2016 5:51 AM, [yiling\_91@...](mailto:yiling_91@...) [PSYCHTOOLBOX] wrote:  

> > I'm trying to set up an experimental script.
> > 
> > One of the response collected are correct or incorrect responses to math equations.
> > 
> > I would like to generate simple addition, multiplication, division math equations with predefined answers and these answers will either be correct or incorrect, to be judged by the participant.
> > 
> > 3 equations will appear at once on screen then be judged one by one if it's c orrect o r incorrect
> > 
> > for example:
> > 
> > 3+5 =8
> > 
> > 4+9=12
> > 
> > 1+3=4
> > 
> > At the moment, I've c reated t he cell:
> > 
> > EasyCorrect = {'3+4=7', '2+12=14', '4+4=8', '5+7=12', '7+8=15', '15-4=11', '18-11=7', '15-5=10', '16-8=8', '13-9=4'};
> > 
> > msize = numel (EasyCorrect)
> > 
> > Easy\_Correct = EsayCorrectrandperm(msize, 1))
> > 
> > These commands would randomly select one equation from the EasyCorrect array.
> > 
> > The problem now is:
> > 
> > 1. how do I display this on screen?
> > 
> > 2. how do I display all three sets of equations at the same time?
> > 
> > Presumable, a function such as this:
> > 
> > DrawFormattedText(mainwin, char(Easy\_Correct), 'Center', 'Center')
> > 
> > But it doesn't work...!!
> > 
> > Any help would be much appreciated

---

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [March 17, 2016, 1:24pm UTC](https://psychtoolbox.discourse.group/t/randomise-stimuli-display-on-screen-psychtoolbox/1931/3 "2016-03-17T13:24:20Z")

</div>

sorry, typo, it would be DrawFormattedText(mainwin, Easy\_Correct{1}, 'Center', 'Center')  
   
 - Will  
   

On 3/17/2016 8:58 AM, Will Hopper [whopper@...](mailto:whopper@...) [PSYCHTOOLBOX] wrote:  

> > Judging by your example, the first thing you'll have to do is index the Easy\_Correct cell array to select out one of the strings representing the equations, e.g.   
> >   
> > DrawFormattedText(mainwin, (Easy\_Correct{1}, 'Center', 'Center')  
> >   
> > Also, are you calling Screen('Flip') after calling DrawFormattedText? Screen('Flip') is the function that actually updates the display.  
> >   
> > Sorry if I'm telling you something you already know, but it would be helpful if you included a more of a reproducible example of the code you are running, so people don't have to assume what you are/are not doing.   
> >   
> > - Will
> > 
> > On 3/17/2016 5:51 AM, [yiling\_91@...](mailto:yiling_91@...) [PSYCHTOOLBOX] wrote:  
> > 
> > > I'm trying to set up an experimental script.
> > > 
> > > One of the response collected are correct or incorrect responses to math equations.
> > > 
> > > I would like to generate simple addition, multiplication, division math equations with predefined answers and these answers will either be correct or incorrect, to be judged by the participant.
> > > 
> > > 3 equations will appear at once on screen then be judged one by one if it's c orrect o r incorrect
> > > 
> > > for example:
> > > 
> > > 3+5 =8
> > > 
> > > 4+9=12
> > > 
> > > 1+3=4
> > > 
> > > At the moment, I've c reated t he cell:
> > > 
> > > EasyCorrect = {'3+4=7', '2+12=14', '4+4=8', '5+7=12', '7+8=15', '15-4=11', '18-11=7', '15-5=10', '16-8=8', '13-9=4'};
> > > 
> > > msize = numel (EasyCorrect)
> > > 
> > > Easy\_Correct = EsayCorrectrandperm(msize, 1))
> > > 
> > > These commands would randomly select one equation from the EasyCorrect array.
> > > 
> > > The problem now is:
> > > 
> > > 1. how do I display this on screen?
> > > 
> > > 2. how do I display all three sets of equations at the same time?
> > > 
> > > Presumable, a function such as this:
> > > 
> > > DrawFormattedText(mainwin, char(Easy\_Correct), 'Center', 'Center')
> > > 
> > > But it doesn't work...!!
> > > 
> > > Any help would be much appreciated
