function dataout = ldpc_dataExtraction(datain,Z,starti,endi,n,serial)
   if serial
       veclength = 1;
       idx = starti:endi;
       tmp = squeeze(datain)';
       dataout = tmp(idx)';
   else
       veclength = 64;
       dataOutVec64Format = [true(1,Z) false(1,veclength*ceil(Z/veclength)-Z)];
       idx = starti:endi;
       tmp = squeeze(datain);
       data_vec  = reshape(tmp(:,idx),[],1)';
       dataout   = data_vec(repmat(dataOutVec64Format,1,n))';
   end
end