Get corresponding value of a 3D matrix using an index vector
12 views (last 30 days)
Show older comments
Hello,I have a 3D matrix, dimesion 37*30*1000. And an index vector i, dimension 37*1, containing the index of the column I want to get the value for each row from 1--> 37
Could anyone tell me how to get the 37*1*1000 new matrix from the original matrix and the index vector?
Thank you,
Answers (1)
KSSV
on 24 Oct 2018
A = rand(37,30,100) ;
C = 3 ; % say you need third columns from each
iwant = zeros(37,1,100) ;
for i = 1:100
iwant(:,1,i) = A(:,C,i) ;
end
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!