A matrix of numbers is a collection of numbers arranged into a fixed number of rows and columns. A matrix can also be defined as a rectangular array of numbers. The dimensions of a matrix are given by the (number of rows)*(number of columns).
An example of a matrix is A= [ 1 2 3
4 5 6]
The dimension of the above matrix is 2*3 as there are 2 rows and 3 columns.
The individual items in an m*n matrix A, often denoted by ai,j , where max i = m and max j =n , are called its elements or entries.
Matrices are very important especially in the area of image processing and computer vision.
We will be using a library called as numpy for our computations. Numpy can be installed by the following steps.
- Type cmd in the Search.Click Enter. This takes you to the command prompt window.
- Type ‘pip install numpy’ and press Enter.
- The installation will take place.
If you face any issue or encounter errors during the installation of numpy, please comment below.
Numpy is imported or used by adding the command “import numpy” in the beginning of the program. You can generally see that people use “import numpy as np” instead of “import numpy”.The “import as” syntax simply allows you to bind the import to the local variable name of your choice.
Let us define a matrix using Numpy package and try some basic operations.