flip an array with the use of vectors
Show older comments
I would like to flip specific cells in an array, not the whole array, with the use of vectors. For example a=[1 7 5 9 3 2 4 1] and i want to flip it from 5 to 2 and make it a=[1 7 2 3 9 5 4 1]. Any suggestions? Thank you in advance.
Accepted Answer
More Answers (1)
Meg Noah
on 12 Jan 2020
a=[1 7 5 9 3 2 4 1];
a(3:6) = fliplr(a(3:6));
Categories
Find more on Matrix Indexing 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!