Data Truncation

As explained in Section 14.4.2, data needs to of a size that is always representable by a set of segments from the defined segment set. Therefore, we need to truncate the data to a multiple of max_segment_size samples. We choose max_segment_size, so that all or most segment sizes are factors. The ideal value is the least common multiple of Ns:
   % 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.