Generate catch trial numbers in blocks of a certain length
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I am doing an experiment and I want to insert a certain amount of catch trials randomly during my experiment. It is important that these catch trials are more or less equally spaced troughout the experiment. Right now I solved it in the following way:
%% A function to randomly create the intances of the catch trials
% By Bram van Adrichem
clear all
close all
clc
NrTrials = 150;
NrEC = 15;
NrCatchTrials = 15;
NrData = NrTrials/NrEC;
BlockStart = 2;
RandomNumber = CatchTrialMoment(NrTrials,NrCatchTrials,BlockStart);
function RandomNumber = CatchTrialMoment(NrTrials,NrCatchTrials,BlockStart)
BlockLength = NrTrials/NrCatchTrials;
for ii = 1:NrCatchTrials
RandomNumber(ii) = (BlockLength*(ii-1)) + datasample(BlockStart:BlockLength,1);
end
end
I think this code works, but my two question are:
Is there already a matlab function that can do this?
Are there more people struggling with this kind of problem, because then I could upload it to the file- exchange
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!