1 |
|
2 |
|
3 | # Function size
|
4 |
|
5 | Calculate the size of a matrix or scalar.
|
6 |
|
7 |
|
8 | ## Syntax
|
9 |
|
10 | ```js
|
11 | math.size(x)
|
12 | ```
|
13 |
|
14 | ### Parameters
|
15 |
|
16 | Parameter | Type | Description
|
17 | --------- | ---- | -----------
|
18 | `x` | boolean | number | Complex | Unit | string | Array | Matrix | A matrix
|
19 |
|
20 | ### Returns
|
21 |
|
22 | Type | Description
|
23 | ---- | -----------
|
24 | Array | Matrix | A vector with size of `x`.
|
25 |
|
26 |
|
27 | ## Examples
|
28 |
|
29 | ```js
|
30 | math.size(2.3) // returns []
|
31 | math.size('hello world') // returns [11]
|
32 |
|
33 | const A = [[1, 2, 3], [4, 5, 6]]
|
34 | math.size(A) // returns [2, 3]
|
35 | math.size(math.range(1,6)) // returns [5]
|
36 | ```
|
37 |
|
38 |
|
39 | ## See also
|
40 |
|
41 | [count](count.md),
|
42 | [resize](resize.md),
|
43 | [squeeze](squeeze.md),
|
44 | [subset](subset.md)
|