Alternatively, you can use simple indexing:
>> M = rand(3,4,5);
>> M(:, end:-1:1, :);
This is a lot faster and less resource intensive than flipdim
, and I think a lot cleaner too.
However, for some people, this particular usage of the end
keyword is confusing, so if you're one of those people, flipdim
will do just fine :)