MATLAB: I have a data matrix each for 100 persons.Initially I was dividing columns into four segments (see code below). Now this data matrix vary, instead of 10000, the columns have different lengths. How can i divide them into 4 segments

dividing columns of various length into 4 equal segments for 100 persons

data_10_col = data(:,[1:10000]);
for e = 1:4
epoch(e,:) = data_10_col(1+(e-1)*2500:e*2500);
end

Best Answer

YOu can use reshape to achieve what you want.
A = rand(100,3) ; % 100 rows of some data
[nx,ny] = size(A) ;
B = reshape(A',ny,[],4) ;
iwant = permute(B,[2,1,3]);