Function size #

Calculate the size of a matrix or scalar. Always returns an Array containing numbers.

Note that in mathjs v14 and older, function size could return a Matrix depending on the input type and configuration.

Syntax #

math.size(x)

Parameters #

Parameter Type Description
x boolean | number | Complex | Unit | string | Array | Matrix A matrix

Returns #

Type Description
Array A vector with size of x.

Throws #

Type | Description —- | ———–

Examples #

math.size(2.3)                       // returns []
math.size('hello world')             // returns [11]

const A = [[1, 2, 3], [4, 5, 6]]
math.size(A)                         // returns [2, 3]
math.size(math.range(1,6).toArray()) // returns [5]

See also #

count, resize, squeeze, subset

Fork me on GitHub