Given some multidimensional matrix A. Get a matrix of the same size as A where all elements are replaced by their index along the kth dimension
Example
Input
A = ans(:,:,1) =
1 3 6 2
ans(:,:,2) =
6 9 7 6
Output:
f(A,1) = ans(:,:,1) =
1 1 2 2
ans(:,:,2) =
1 1 2 2
f(A,2) = ans(:,:,1) =
1 2 1 2
ans(:,:,2) =
1 2 1 2
f(A, 3) =
ans(:,:,1) =
1 1 1 1
ans(:,:,2) =
2 2 2 2
Deterministic solution would fail if you add at least one more test case for the 2-D or 4-D arrays.
Back to basics 22 - Rotate a matrix
682 Solvers
Put Two 1D matrices into one 1D matrix
91 Solvers
410 Solvers
Find out sum of prime number till given number
92 Solvers
Matlab Basics II - Count rows in a matrix
178 Solvers