[Solved] Given a row vector, how do I create an indicator matrix placing each value in its respective column location?
Another approach is through bsxfun and unique. Assuming that A is a row vector, you would do the following: un = unique(A.’, ‘stable’); out = bsxfun(@times, bsxfun(@eq, A, un), un); out contains your desired result. This code deserves some explanation. The first line of code determines all unique entries in A stored in un, but … Read more