I am programming an experiment. Let's say that my experiment has 13 different conditions. Each condition is presented twice per block. There are two blocks in total. This makes a total of 52 trials.
conditions = repmat(1:13,1,4)
I can randomize the variable condition.
conditionsrand = conditions(randperm(length(conditions)))
However, I would like to do this randomization by block. That is every 26 trials there should be two instances of each condition. I think that this must be something easy, but I cannot find the solution.
Any idea?
Thanks!

 Akzeptierte Antwort

Jos (10584)
Jos (10584) am 25 Jun. 2018
Bearbeitet: Jos (10584) am 25 Jun. 2018

0 Stimmen

C = repmat(1:13,1,2) % conditions per block
% [block1 block2]
rC = [C(randperm(numel(C))) C(randperm(numel(C)))] % *corrected

3 Kommentare

Alejandro Estudillo
Alejandro Estudillo am 25 Jun. 2018
Thanks for your reply! It gives me the following error
rC = [C(randperm(numel(C)) C(randperm(numel(C))] ↑ Error: Unexpected MATLAB expression.
In addition, each condition is presented 2 times per block, hence repmat(1:13,1,4). Also, I will have to increase the number of blocks to 100, so maybe the instructions rC = [C(randperm(numel(C)) C(randperm(numel(C))] will become too tedious?
THanks!
I forgot two closing brackets, which is now corrected. Do you want to create all trials at once? An easy alternative:
C = 1:5
numC = numel(C)
numCperBlock = 2
numBlocks = 3
[~,r] = sort(rand(numC, numCperBlock * numBlocks))
rC = reshape(C(r),1,[])
Alejandro Estudillo
Alejandro Estudillo am 26 Jun. 2018
thanks! that works perfectly!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by