Main Content

# finddim

Find dimensions with specified label

## Syntax

``dim = finddim(dlX,label)``

## Description

example

````dim = finddim(dlX,label)` returns the dimensions in `dlX` that have the label `label`. If no dimension matches `label`, `dim` is empty.```

## Examples

collapse all

Create a `dlarray` with some repeated labels. Specify the labels as `'TSSU'`. The `dlarray` call reorders the labels, because it enforces the order `'SCBTU'`. See Usage.

`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×2 1 2 ```

Obtain the dimensions with the label `'B'`.

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

Obtain the size of the `dlX` dimensions labeled `'S'`.

`SSize = size(dlX,finddim(dlX,'S'))`
```SSize = 1×2 4 3 ```

## Input Arguments

collapse all

Input `dlarray`, specified as a `dlarray` object.

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

Single `dlarray` label, specified as one of these characters:

• `S` — Spatial

• `C` — Channel

• `B` — Batch observations

• `T` — Time or sequence

• `U` — Unspecified

Example: `"C"`

Data Types: `char` | `string`

## Output Arguments

collapse all

Dimension, returned as a real vector. If no label in the input array `dlX` matches `label`, `dim` is empty. So if `dlX` is unlabeled, `dim` is empty.

## See Also

Introduced in R2019b

Download ebook