function ind = end(obj,k,n)
%Helper for computing end within an indexing statement.
%
%  Hidden method of dlarray.

%   Copyright 2019 The MathWorks, Inc.

if k == n
    % ind = prod(size(obj, n:ndims(obj)))
    ind = 1;
    for ii=n:ndims(obj)
        ind = ind * size(obj, ii);
    end
else
    ind = size(obj, k);
end
end
