interesting matrix indexing question without for loops
Show older comments
size(matrixA)=[b,n,m]
size(matrixB)=[n,m]
how can I create
matrixC(i,j)=matrixA(matrixB(i,j),i,j)
without using for-loops? What is this kind of indexing called? Thanks!
Accepted Answer
More Answers (1)
Bruno Luong
on 3 Oct 2018
Edited: Bruno Luong
on 3 Oct 2018
C = A(B+reshape(0:numel(B)-1,size(B))*size(A,1))
1 Comment
Chris Hooper
on 3 Oct 2018
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!