we want to modify our randomization, to let matlab rerandomize the order (1-12) if some conditions are met.
So when the restrictions are met, we want the for loop to break, set z=0 to rerandomize within the while loop.
Only if none of the restrictions are violated, we want to set z=1 so that the randomization would not be executed again.
However this is not working with the following code, after running it a few times, some of the randomizations do not follow our conditions … can anyone help? Thanks in advance
z=0;while z==0 randStim = stimuli(randperm(size(stimuli,1)/2),:); randomizeOrder(randomizeOrder(:,4)==1,7)=randStim; for i=1:10 if randomizeOrder(randomizeOrder(:,7)==i,5) == randomizeOrder(randomizeOrder(:,7)==i+1,5) == randomizeOrder(randomizeOrder(:,7)==i+2,5) || ... randomizeOrder(randomizeOrder(:,7)==i,2) == randomizeOrder(randomizeOrder(:,7)==i+1,2) == randomizeOrder(randomizeOrder(:,7)==i+2,2) || ... randomizeOrder(randomizeOrder(:,7)==i,6) == randomizeOrder(randomizeOrder(:,7)==i+1,6) == randomizeOrder(randomizeOrder(:,7)==i+2,6) z=0; break else z=1; end endend
Best Answer