table.numel
table: out = numel (tbl)
Total number of elements in table.
out = numel (tbl) returns the number of elements in
the table, tbl, equivalent to prod (size (tbl)). A
table is treated as a two-dimensional container, so this is the number of
rows times the number of variables. Variables may themselves span
multiple columns, but numel only accounts for the number of rows
and the number of variables, not the underlying columns.
Source Code: table
For a table numel returns rows times variables — the number of table cells — not the count of underlying data elements. This 3-by-2 table therefore has 6 cells even though BloodPressure holds two columns.
Age = [38; 43; 40]; Smoker = logical ([1; 0; 1]); BloodPressure = [124, 93; 109, 77; 117, 75]; T = table (Age, Smoker, BloodPressure)
T =
3x3 table
Age Smoker BloodPressure
___ ______ _____________
38 true 124 93
43 false 109 77
40 true 117 75
numel (T)
ans = 9
It is simply the product of height and width.
height (T) * width (T)
ans = 9