Skip to content

flipdim

Flipping array along a specified dimension.

flipdim(A)

  • It returns an array of the same size as A, whose elements along the first non-singleton dimension have reversed orders.

flipdim(A, dim)

  • The output is an array of the same size of A, whose elements along the dim-th dimension have reversed orders.

Example 1: Flipping a 3 dimensional array in 3 different directions.

a=reshape(1:8, 2, 2, []);
a1=flipdim(a,1)
a2=flipdim(a,2)
a3=flipdim(a,3)
a1(:, :, 1) = 

 2.000   4.000
 1.000   3.000

a1(:, :, 2) = 

 6.000   8.000
 5.000   7.000

a2(:, :, 1) = 

 3.000   1.000
 4.000   2.000

a2(:, :, 2) = 

 7.000   5.000
 8.000   6.000

a3(:, :, 1) = 

 5.000   7.000
 6.000   8.000

a3(:, :, 2) = 

 1.000   3.000
 2.000   4.000