function l = length( D )
%LENGTH Length of distributed vector
%   L = LENGTH(D)
%   
%   Example:
%       N = 1000;
%       D = distributed.zeros(0,N,0);
%       l = length(D)
%   
%   returns l = 0.
%   
%   See also LENGTH, DISTRIBUTED, DISTRIBUTED/ZEROS.


%   Copyright 2006-2020 The MathWorks, Inc.

% Table explicitly forbids access to LENGTH, and throws a specific error.
if isUnderlyingType(D, 'table') || isUnderlyingType(D, 'timetable')
    error(message('MATLAB:table:UndefinedLengthFunction', underlyingType(D)));
end

sz = size( D );
if min( sz ) == 0
    l = 0;
else
    l = max( sz );
end
end
