Matrix Operations using Python

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,, 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.

  1. Type cmd in the Search.Click Enter. This takes you to the command prompt window.
  2. Type ‘pip install numpy’ and press Enter.
  3. 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.

screenshot-32.png

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: