function w = width(x)
%WIDTH Number of columns/variables in a tall array, tall table or timetable.
%   W = WIDTH(X)
%
%   See also TALL/HEIGHT, TALL/SIZE, TALL/NUMEL.

% Copyright 2015-2020 The MathWorks, Inc.

isTabular = ismember(tall.getClass(x), {'table', 'timetable'});
if isTabular
    w = x.Adaptor.Size(2);
else
    w = size(x, 2);
end
