## Matrices

Matrices are an ordered collection of equal length lists separated by commas and surrounded by a pair of square brackets.

Elements of a matrix can be accessed by assigning the matrix to a variable or using the transformation operator. Matrices like lists are 1-indexed in MathStudio meaning the first element starts at index 1.

Matrix rows and elements can be accessed using an integer, range, list of integers or a matrix of integers.

## Creating Matrices

[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
[1:3, 4:6, 7:9]
@[3, 3]
@[4, 3, 3]

## Set a column to a value

b = @[3, 3] b(*, 2) = 1 b

## Set a submatrix to a value

b = @[4, 4] b(2..3, 2..3) = 1 b

## Set a submatrix to another submatrix

b = @[4, 4] b(2..3, 2..3) = [[1, 2], [3, 4]] b

[[1, 2, 3]]'

Identity(3)

## Accessing elements in a matrix

m=[[1, 2, 3], [4, 5, 6], [7, 8, 9]] m(2, 1)

## Accessing a column in a matrix

m=[[1, 2, 3], [4, 5, 6], [7, 8, 9]] m(*, 2)

## Combining matrices using the transformation operator

[[1, 2, 3], [4, 5, 6]] -> [[7, 8, 9]]

## Submatrices using the transformation operator

[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]] -> 2..3

## Iterate over a matrix

m = @[10, 10] for [row, column] in m m(row, column) = row * column end m

## Drawing a matrix

ImagePlot(Identity(10), width=200, height=200)
data = @[29, 29] for [row, column] in data data(row, column) = gcd(row, column) > 1 end ImagePlot(data, width=200, height=200)

## References

http://en.wikipedia.org/wiki/Matrix_(mathematics)

## Related Functions

Cholesky, Det, Eigenvalues, Eigenvectors, Flatten, Identity, Inverse, MatrixLU, MatrixQR, MatrixSVD, RowReduce, Transpose