Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
Sheena

Junior Member
Registered:
Posts: 13
Reply with quote  #1 
Is it possible to define global variables?

For example, 
I use gen function to create a random orientation arrow for each trial. Then, I need to record the orientation and use this value in the next trial.

Moreover, I need pseudo-random orientations.
Can I define a matrix of orientation values (e.g. 100 values in total), then use each value for each different trial (e.g. 100 trials in total)?


My ML version: MonkeyLogic_stable-1.2.85 with NIMH_daqtoolbox_(May-19-2016)

Thanks.
0
Jaewon

Administrator
Registered:
Posts: 971
Reply with quote  #2 
Are you asking how to define global variables or whether you may define global variables? If it is the former, see the MATLAB documentation about 'global' or 'persistent'. If it is the latter, you will know the answer when you try.
0
kaciedougherty

Junior Member
Registered:
Posts: 12
Reply with quote  #3 
Yes, using a global variable to define stimulus parameters can work. In order to generate stimuli for experiments with many conditions, you can write a function that pseudo-randomizes conditions and defines the stimulus parameters for a set of trials at the start of the task. The output of this function is a global variable. (We have done this by generating a structure, with each field defining different stimulus parameters (orientation, spatial freq, etc.).

To generate this global variable at the start of each file, you can add a call to this function in your gen function (the one that generates the stimulus on every trial) on the first trial AND and when the current trial number exceeds the length of the global variable (in other words, if you keep running the ML task you might reach the end of your global variable and need a new set of pseudo-randomized trials). 

To make the stimulus on each trial, you can get the current trial number from the TrialRecord structure and use that to pull out what you need from your global variable. 

To save the stimulus condition info, you can write to a text file on each trial. 
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.