Matrix
Matrices allow you to store multiple values in a single variable.
Use matrices/arrays to store and manipulate multiple values. You can:
- create a matrix by using the square brackets
[]
in a math block, such as[1, 2, 3]
. - assign matrices to variables just like numbers, such as
X = [1, 2, 3]
. - use units in your matrices, such as
X = [1 kg, 2 kg, 3 kg]
. - create higher-dimensional matrices, such as
X = [[1, 2, 3], [4, 5, 6]]
. - use matrix operations and functions to perform calculations on matrices, such as
X * Y
orX + Y
.
Result Table
To help with viewing matrix results, we've added a result table that can be shown by:
Matrix Operations
See operations for more information regarding matrix operations and matrix-related functions.
Accessing Matrix Values
Stride uses 1-based matrix indices, so the first element of a 2D matrix is [1,1]
. In the example of a 2 dimensional m x n
matrix named X
, use the following syntax to access values and sub matrices.
Syntax | Description |
---|---|
X[m,n] | Access the element at row m and column n |
X[m,:] | Access the row m |
X[:,n] | Access the column n |
X[a:b,c:d] | Access the sub-matrix from row a to row b and column c to column d |
X[a:,b:] | Access the sub-matrix from row a to the end and column b to the end |
X[:a,:b] | Access the sub-matrix from row 1 to row a and column 1 to column b |
Last updated on