%% Rearrange Array to Operate on First Nonsingleton Dimension
% This example shows how shiftdata and unshiftdata work when you define dim as empty.
% Define x as a row vector.

x = 1:5

%
% Define dim as empty to shift the first nonsingleton dimension of x to the first column. shiftdata returns x as a column vector, along with perm, the permutation vector, and nshifts, the number of shifts.

[x,perm,nshifts] = shiftdata(x,[])

%
% Using unshiftdata, restore x to its original shape.

y = unshiftdata(x,perm,nshifts)

% Copyright 2015 The MathWorks, Inc.