index.md (1099B)
1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. --> 2 3 # Function index 4 5 Create an index. An Index can store ranges having start, step, and end 6 for multiple dimensions. 7 Matrix.get, Matrix.set, and math.subset accept an Index as input. 8 9 10 ## Syntax 11 12 ```js 13 math.index(range1, range2, ...) 14 ``` 15 16 ### Where 17 18 - A number 19 - A string for getting/setting an object property 20 - An instance of `Range` 21 - A one-dimensional Array or a Matrix with numbers 22 23 ### Parameters 24 25 Parameter | Type | Description 26 --------- | ---- | ----------- 27 `ranges` | ...* | Zero or more ranges or numbers. 28 29 ### Returns 30 31 Type | Description 32 ---- | ----------- 33 Index | Returns the created index 34 35 36 ## Examples 37 38 ```js 39 const b = [1, 2, 3, 4, 5] 40 math.subset(b, math.index([1, 2, 3])) // returns [2, 3, 4] 41 42 const a = math.matrix([[1, 2], [3, 4]]) 43 a.subset(math.index(0, 1)) // returns 2 44 ``` 45 46 47 ## See also 48 49 [bignumber](bignumber.md), 50 [boolean](boolean.md), 51 [complex](complex.md), 52 [matrix](matrix.md), 53 [number](number.md), 54 [string](string.md), 55 [unit](unit.md)