Shift data to operate on specified dimension

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

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

shifts
data `x`

to permute dimension `dim`

to
the first column using the same permutation as the built-in `filter`

function. The vector `perm`

returns
the permutation vector that is used.

If `dim`

is missing or empty, then the first
nonsingleton dimension is shifted to the first column, and the number
of shifts is returned in `nshifts`

.

`shiftdata`

is meant to be used in tandem with `unshiftdata`

, which shifts the data back
to its original shape. These functions are useful for creating functions
that work along a certain dimension, like `filter`

, `goertzel`

, `sgolayfilt`

,
and `sosfilt`

.

Was this topic helpful?