Given an array:
array1 = [1 2 3];
I have to reverse it like so:
array1MirrorImage = [3 2 1];
So far I obtained this ugly solution:
array1MirrorImage = padarray(array1, [0 length(array1)], 'symmetric', 'pre'); array1MirrorImage = array1MirrorImage(1:length(array1));
Is there a prettier solution to this?
UPDATE: In newer versions of MATLAB (R2013b and after) it is preferred to use the function
flipinstead offlipdim, which has the same calling syntax:Tomas has the right answer. To add just a little, you can also use the more general
flipdim:An additional little trick… if for whatever reason you have to flip BOTH dimensions of a 2-D array, you can either call
flipdimtwice:or call
rot90: