y=fold(x,epochsize) - fold 2D to 3D y: 3D matrix of (time * channel * trial) x: 2D matrix of concatentated data (time * channel) epochsize: number of samples in each trial NoiseTools
0001 function x=fold(x,epochsize) 0002 %y=fold(x,epochsize) - fold 2D to 3D 0003 % 0004 % y: 3D matrix of (time * channel * trial) 0005 % 0006 % x: 2D matrix of concatentated data (time * channel) 0007 % epochsize: number of samples in each trial 0008 % 0009 % NoiseTools 0010 0011 nt_greetings; 0012 0013 if isempty(x); 0014 x=[]; 0015 else 0016 if size(x,1)/epochsize>1 0017 x=permute(reshape(x,[epochsize, size(x,1)/epochsize, size(x,2)]), [1 3 2]); 0018 else 0019 x=x; 0020 end 0021 end