%% 4-D Array
% Create a 4-by-2-by-3-by-5 array. Shift the dimensions 2 positions to the left, wrapping the first 2 lengths to the last 2 dimensions.

A = rand(4,2,3,5);
B = shiftdim(A,2);
size(B)

% Shift the dimensions 2 positions to the right, resulting in 2 leading dimensions of length 1. Shifting to the right does not wrap the dimension lengths.

C = shiftdim(A,-2); 
size(C)

% Copyright 2018 The MathWorks, Inc.