Main Content

finddim

Find dimensions with specified label

Description

example

dim= finddim(dlX,label)returns the dimensions indlXthat have the dimension labellabel. If the data format ofdlXdoes not contain the dimension labellabel,dimis empty.

Examples

艾尔崩溃l

Create a formatteddlarraywith some repeated dimension labels. Specify the dimension labels as'TSSU'. Thedlarraycall reorders the labels, because it enforces the order'SCBTU'. For more information about dimension labels, seeUsage.

dlX = dlarray(randn(5,4,3,2),'TSSU');

Obtain the dimensions with the label'T'.

dimU = finddim(dlX,'T')
dimU = 3

Obtain the dimensions with the label'S'.

dimS = finddim(dlX,'S')
dimS =1×21 2

Obtain the dimensions with the label'B'.

dimB = finddim(dlX,'B')
dimB = 1x0 empty double row vector

Obtain the size of thedlXdimensions labeled'S'.

SSize = size(dlX,finddim(dlX,'S'))
SSize =1×24 3

Input Arguments

艾尔崩溃l

Inputdlarray, specified as adlarrayobject.

Example:dlX = dlarray(randn(3,4),'ST')

Single dimension label, specified as one of the followingdlarraydimension labels:

  • S— Spatial

  • C— Channel

  • B— Batch observations

  • T— Time or sequence

  • U— Unspecified

Example:"C"

Data Types:char|string

Output Arguments

艾尔崩溃l

Dimension, returned as a real vector. If no label in the input arraydlXmatcheslabel,dimis empty. So ifdlXis unformatted,dimis empty.

Extended Capabilities

Introduced in R2019b