How can I rearrange an array based on the order indicated by another array?

Ex:
Order = [8, 19, 1, 13, 4, 14, 11, 2, 15, 12, 17, 3, 7, 12, 6, 11, 7, 19, 13, 15, 2, 18, 9, 1, 20, 10, 3, 16, 8, 20, 5, 16, 9, 6, 17, 10, 5, 14, 4, 18];
A = [1.1, 1.35, 2.15, 2.25, 2.25, 2.35, 1.85, 1.35, 1.2, 1.05, 1, 1.1, 0.7, 0.7, 0.95, 0.6, 0.8, 1.2, 1.6, 1.05];
I want to rearrange A/create a new array according to the order specified in array "Order" (i.e, pick the 8th value of A, then the 19th, ...)

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!