data-structures

Matrices

Remarks#

This article aims to explain what a matrix is and how to use it.

Intro to matrices

Matrices are essentially two-dimensional arrays.

That means that it associates (i, j) coordinates, where i is the row and j is the column, to a value.

So, you could have :

m3, 4 = “Hello”

The easiest implementation is to make an array or arrays. In python, that would go as follows.

matrix = [["a", "b", "c"], ["d", "e", "f"], ["g", "h", "i"]]
print(matrix[1][2]) #returns "f"    

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow