I'm trying to find unique slices of a multi-dimensional array. For example, if I have something like
A = repmat(magic(4),1,1,3);A(:,:,2) = A(:,:,2) - 1A(:,:,1) = 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1A(:,:,2) = 15 1 2 12 4 10 9 7 8 6 5 11 3 13 14 0A(:,:,3) = 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1
I would like to be able to call something (with the dimension along which I'm slicing specified) and get
[C, ia, ic] = highdim_unique(A, 3) C(:,:,1) = 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1C(:,:,2) = 15 1 2 12 4 10 9 7 8 6 5 11 3 13 14 0ia = 1 2ic = 1 2 1
Any chance that something like this exists or has a straightforward solution? Ideally I would want to do this for arbitrariliy many dimensions, but doing it in 3 would be fine.
Thanks,
Jake
Best Answer