strings pseudo-randomization plus constraints
1 次查看(过去 30 天)
显示 更早的评论
Dear all,
I'm about to randomize my stimuli for an experiment. Each stimulus corresponds to an audio-file, whose name might be like the following:
ALPHA_BETA_AA_01 or
ALPHA_BETA_BB_01 or
ALPHA_BETA_CC_01 or ...
ALPHA_BETA_CC_48
I have six conditions with 48 stimuli each, plus six conditions with 12 stimuli each.
My goal is to randomize my conditions.
I use to import my list of 360 strings with textread, so that I have
M <360x1 cell>
I'm looking for a way to randomize my stimuli so that no more that three stimuli of the same condition would appear in succession.
As a clarification, the labelling I'm using for my files (i.e. ALPHA_BETA_AA_1) stands for:
ALPHA_BETA %is the name of the file
_AA %is the name of the condition
_01 %is the ordering number
Any suggestion is highly appreciated!
Sincerely,
Udiubu
P.S. I found the "shake" function by Jos van der Geest on the File Exchange, but still, I don't know how to constrain my script.
2 个评论
Walter Roberson
2012-5-15
Are the six conditions with the 48 stimuli named differently than the 6 with the 12 stimuli? If not then do the ones that are named the same between the two groups to be considered the same or different?
回答(1 个)
Walter Roberson
2012-5-15
codes = [101:148,201:212];
need_valid = true;
while need_valid
randcodes = codes(randperm(length(codes)));
need_valid = ~isempty(strfind(floor(randcodes ./ 100), [0 0]));
end
At this point, randcodes encodes the ordering, with the hundreds digit of each location indicating which of the two conditions it is, and with the last two digits indicating the stimuli within the condition.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!