function obj = addTrailingODims(obj, nd)
%ADDTRAILINGODIMS Add trailing singleton dimensions in obj
%
% OBJ = ADDTRAILINGODIMS(obj, ND) adds trailing 'U' format labels to
% dlarrays that have format labels, to ensure that obj has ndims == nd.

%   Copyright 2019 The MathWorks, Inc.

ndNow = ndims(obj);
if hasFormat(obj) && ndNow<nd
    obj.FormattedData.DimensionMetadata(end+1:nd) = 'U';
    
    if ~isempty(obj.DataToViewMap)
        obj.DataToViewMap(end+1:nd) = ndNow+1:nd;
        obj.ViewToDataMap(end+1:nd) = ndNow+1:nd;   
    end
end
