% find least common multiple max_segment_size=Ns(1); for i=2:nfeat, max_segment_size=lcm(max_segment_size,Ns(i)); end; fprintf('max_segment_size=',%d\n',max_segment_size=); % truncate the data to a multiple of max_segment_size for i=1:length(X), n=floor(length(X{i})/max_segment_size)*max_segment_size; X{i}=X{i}(1:n); ntot(i)=n; end;Note that we store the length of each data sample in variable ntot.