I'd like to replicate an NxM matrix into an NxMx3 matrix, i.e. have 3 copies of the input matrix in the third dimension. How do I do that?
+1
A:
If A is your NxM matrix, then the NxMx3 matrix is:
B = hypermat([size(A), 3], kron(ones(3, 1), A(1:$)))
or
B = hypermat([size(A), 3], ones(3, 1).*.A(1:$))
Aditya Sengupta
2010-09-22 12:20:31