Date: Feb 1, 2013 9:04 AM
Author: Bruno Luong
Subject: Re: index end-point to matrix

k = b > 0;
c = b(k);
l = diff([0 c]);
s = c(end);
c(end) = [];
i = zeros(1,s);
i(c+1) = 1;
i = 1+cumsum(i);
j = ones(1,s);
j(c+1) = 1-l(1:end-1);
j = cumsum(j);
a = zeros(length(b), max(j));
a(k,:) = accumarray([i(:) j(:)], (1:s)')

% Bruno