Naresh
Posts:
7
Registered:
12/7/04


Re: index endpoint to matrix
Posted:
Feb 4, 2013 11:24 AM


Bruno,
Both methods work for me but I think the second solution is a brilliant use of bsxfun. Thanks for your reply.
Naresh
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <keimvi$15k$1@newscl01ah.mathworks.com>... > Another method: > > k = b > 0; > c = b(k); > l = diff([0 c]); > m = bsxfun(@le,(1:max(l))',l); > r = zeros(size(m)); > r(m) = 1:c(end); > a = zeros(length(b), max(l)); > a(k,:) = r' > > % Bruno

