Navigation

Operators and Keywords

Function List:

C++ API

: numel (a)
: numel (a, idx1, idx2, …)

Return the number of elements in the object a.

Optionally, if indices idx1, idx2, … are supplied, return the number of elements that would result from the indexing

a(idx1, idx2, …)

Note that the indices do not have to be scalar numbers. For example,

a = 1;
b = ones (2, 3);
numel (a, b)

will return 6, as this is the number of ways to index with b. Or the index could be the string ":" which represents the colon operator. For example,

a = ones (5, 3);
numel (a, 2, ":")

will return 3 as the second row has three column entries.

This method is also called when an object appears as lvalue with cs-list indexing, i.e., object{…} or object(…).field.

See also: size, length, ndims.

Package: octave