function ind = finddim(obj, dim)
%FINDDIM   Find dimensions with a given label
%   DIM = FINDDIM(X, LABEL) takes a one-letter dimension label LABEL and
%   returns a numeric vector of all dimensions in X that match this label.
%   If there is no label in X that matches LABEL, an empty array is
%   returned.
%
%   LABEL can be one of the following dimension labels:
%      - 'S' spatial
%      - 'C' channel
%      - 'B' observations
%      - 'T' sequence
%      - 'U' other
%
%   See also DLARRAY, DIMS, STRIPDIMS, NDIMS

%   Copyright 2019-2020 The MathWorks, Inc.

deep.internal.dlarray.mustBeDataFormatType(dim);
dim = char(dim);
deep.internal.format.validateDataFormat(dim);
if ~isscalar(dim)
    error(message('deep:finddim:InvalidInput'));
end

ind = find(dims(obj) == dim);
end
