From: Jason on
Hi,

Is there an efficient method or builtin function that will fan out
data columns in my matrix? For example, if I start with an unknown
data matrix, M, I'd like to get N in an efficient way than for loops.

M = ones(5,1)*(1:3)
N = fanout(M,3)

where, N should equal:

N = ones(5,1)*[1 1 1 2 2 2 3 3 3]

Any ideas?