How to I reverse the contents of this array?
Show older comments
I have it right for one half of the assignment (4 elements) but not the other. The second part that I have wrong is 3 elements.
function mileMarkers = ReverseArray(mileMarkers)
% mileMarkers: Row array of mile marker values
% Reverse the contents of row array mileMarkers
mileMarkers = mileMarkers(end:-1:end-3)
end
Accepted Answer
More Answers (1)
Image Analyst
on 5 Oct 2017
You can use flipud() or fliplr().
mileMarkers = fliplr(mileMarkers);
1 Comment
Steven Lord
on 5 Oct 2017
If you're using release R2013b or later, you can use flip.
Categories
Find more on Matrices and Arrays 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!