finddim - Find dimensions with specified label - MATLAB (original) (raw)
Main Content
Find dimensions with specified label
Syntax
Description
The finddim
function finds the dimension index of a formatted dlarray
object for a specified label.
[dim](#mw%5F00d27330-1a43-4dd3-b530-770468972acd) = finddim([X](#mw%5F97291a49-61e6-4bfd-b983-9b08ae8e7a76%5Fsep%5Fmw%5F6f734774-5538-44ff-ad05-7e744f97893a),[label](#mw%5F7e0c7d6a-8ec0-457b-b5fd-d440a9a4196d))
returns the dimensions in the dlarray
object X
that have the specified dimension label.
[dim](#mw%5F00d27330-1a43-4dd3-b530-770468972acd) = finddim([layout](#mw%5F26c02e35-a38d-4c01-87ff-cd7ffea36df4),[label](#mw%5F7e0c7d6a-8ec0-457b-b5fd-d440a9a4196d))
returns the dimensions in the networkDataLayout
objectlayout
that have the specified dimension label.
Examples
Find Dimensions of dlarray
Object
Create a formatted dlarray
with format "SSCBT"
(spatial, spatial, channel, batch, time).
X = dlarray(randn(6,5,4,3,2),"SSCBT");
View the dimension labels of X
.
Find the dimensions with the label "S"
.
Find Dimensions of Network Data Layout Object
Create a formatted network data layout object representing 2-D image sequences. Specify the format "SSCBT"
(spatial, spatial, channel, batch, time).
layout = networkDataLayout([227 227 3 NaN 100],"SSCBT");
Find the dimensions with the label "S"
.
dim = finddim(layout,"S")
Input Arguments
X
— Input data
dlarray
object
Input data, specified as a formatted or unformatted dlarray object.
layout
— Network data layout
networkDataLayout
object
Network data layout, specified as a networkDataLayout object.
label
— Dimension label
"S"
| "C"
| "B"
| "T"
| "U"
Dimension label, specified as one of the followingdlarray
dimension labels:
"S"
— Spatial"C"
— Channel"B"
— Batch"T"
— Time"U"
— Unspecified
Output Arguments
dim
— Dimension
vector of positive integers
Dimension, returned as a vector of positive integers.
If the input is unformatted or has no dimension labels that matchlabel, then dim
is empty.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
- The input data must be a
dlarray
object. - The label argument must be a compile-time constant.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Usage notes and limitations:
- The input data must be a
dlarray
object. - The label argument must be a compile-time constant.
Version History
Introduced in R2019b