%% Function: cut data into blocks, based on trial-triggers function [blocks] = cutblockTrial(data,trigs_all,blocklen,nBlck) nTrials = size(trigs_all,3); pSmpl = blocklen/nTrials; blocks = zeros(blocklen,nBlck); for b = 1:nBlck for s = 0:nTrials-1 blocks(s*pSmpl+1:s*pSmpl+pSmpl,b) = data(trigs_all(1,b,s+1):trigs_all(1,b,s+1)+pSmpl-1); % cut block at each trigger point, creating "s" sections of pSmpl per block end end