Number of array elements
If A
is a table, numel
returns
the number of elements in the table, A
, equivalent
to prod(size(A))
. Variables in a table can have
multiple columns, but numel(A)
only accounts for
the number of rows and number of variables.
If A
is a character vector of type char
, then
numel
returns the number of characters. However, if
A
is a string scalar, numel
returns
1
because it is a single element of a string array. For example,
compare the output of numel
for a character vector and
string:
nchar = numel('mytext')
nchar = 6
nstr = numel("mytext")
nstr = 1