How to retrieve multiple values from a 3D array
Show older comments
Dear All,
I have a 3D matrix
I_dd (212x210x245)
and a 2D matrix
occupied_box_indices(4x3) = [156 151 34
156 151 33
156 150 33
177 74 5]
I want to create a vector using these matrcies as below:
I_adress_boxes(1) = I_dd(occupied_box_indices(1,1),occupied_box_indices(1,2),occupied_box_indices(1,3));
I_adress_boxes(2) = I_dd(occupied_box_indices(2,1),occupied_box_indices(2,2),occupied_box_indices(2,3));
I_adress_boxes(3) = I_dd(occupied_box_indices(3,1),occupied_box_indices(3,2),occupied_box_indices(3,3));
I_adress_boxes(4) = I_dd(occupied_box_indices(4,1),occupied_box_indices(4,2),occupied_box_indices(4,3));
With a for loop it can be done very easliy. However, I wonder if is it possible to cerate the I_adress_boxes without for loop and which way do you think is the best in terms of computation time?
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices 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!