Main Content

stripdims

Remove dlarray data format

Since R2019b

Description

example

Y = stripdims(X) returns the dlarray X without any dimension labels. Y is an unformatted dlarray.

example

Y = stripdims(X,fmt) additionally outputs Y with dimensions ordered according to the dimension labels in the format fmt.

Examples

collapse all

Create a formatted dlarray.

dlX = dlarray(randn(3,2,1,2),'SSTU')
dlX = 
  3(S) x 2(S) x 1(T) x 2(U) dlarray


(:,:,1,1) =

    0.5377    0.8622
    1.8339    0.3188
   -2.2588   -1.3077


(:,:,1,2) =

   -0.4336    2.7694
    0.3426   -1.3499
    3.5784    3.0349

Create an array that is the same as dlX but has no dimension labels.

y = stripdims(dlX)
y = 
  3x2x1x2 dlarray


(:,:,1,1) =

    0.5377    0.8622
    1.8339    0.3188
   -2.2588   -1.3077


(:,:,1,2) =

   -0.4336    2.7694
    0.3426   -1.3499
    3.5784    3.0349

Input Arguments

collapse all

Input data, specified as a formatted or unformatted dlarray object.

Description of output data dimensions, specified as a string scalar or character vector.

A data format is a string of characters, where each character describes the type of the corresponding data dimension.

The characters are:

  • "S" — Spatial

  • "C" — Channel

  • "B" — Batch

  • "T" — Time

  • "U" — Unspecified

For example, consider an array containing a batch of sequences where the first, second, and third dimensions correspond to channels, observations, and time steps, respectively. You can specify that this array has the format "CBT" (channel, batch, time).

If fmt is empty or X is an unformatted dlarray object, then Y is equal to X. Otherwise, if X is a formatted dlarray object, then the stripdims function automatically permutes the output so that it has dimensions in the order specified by fmt. In this case, fmt must be a superset of a permutation of dims(X).

Data Types: char | string

Output Arguments

collapse all

Unformatted dlarray, returned as an unformatted dlarray object that is the same as the input array X, but without any dimension labels. If X is unformatted, then Y = X.

Tips

  • Use stripdims to ensure that a dlarray behaves like a numeric array of the same size, without any special behavior due to dimension labels.

  • ndims(X) can decrease after a stripdims call because the function removes trailing singleton dimensions.

    X = dlarray(ones(3,2), 'SCB');
    ndims(X)
    ans =
    
         3
    X = stripdims(X);
    ndims(X)
    ans =
    
         2

Extended Capabilities

Version History

Introduced in R2019b

See Also

| |