MATLAB Answers

Extracting indices from 3D matrix for another 3D matrix

2 views (last 30 days)
Bismark Singh
Bismark Singh on 29 Mar 2020
Answered: Matt J on 6 Apr 2020
I have two 3D matrices A and B, of the same size and another 3d matrix I of the same size containing some indices corresponding to the first dimension of A. I want to do something like A(I)/B(I).
Specifically, A(I(x,y,z),y,z) divide it by B(I(x,y,z),y,z) for all of x,y,z. How do I do it quickly maybe using repmat or sub2ind or simply logical indexing?
If it is not clear I can post an example.

  1 Comment

Jyotsna Talluri
Jyotsna Talluri on 6 Apr 2020
You can use logical indexing in order to access the values from the matrices,but there might be a possibility that the value of I(x,y,z) is greater than the number of rows of matrices A and B

Sign in to comment.

Answers (1)

Matt J
Matt J on 6 Apr 2020


Sign in to comment.

Sign in to answer this question.