## Tutorial Video

Table of contents

## Introduction to Arrays

This a guide which takes you through the basics of arrays including scalars, vectors, matrices and pages. It discusses concepts such as columns and rows in great detail without the use of any MATLAB code by just using an Excel Spreadsheet with no numbers on it to give an overview of the different types of arrays. Once we understand these principles we can go ahead and look at inputting them into MATLAB.

## Scalar – 1 by 1 Array

## Column Vector – m by 1 Array (1D Array)

A Column Vector can be considered as a list of scalars, listed in a column. These can be a list of times, or a list of distances, a list of speeds or a list of prices.

## Row Vector – 1 by n array (1D Array)

A Row Vector can be considered as a list of scalars, listed in a row. This information can just be the same as presented in the Column Vector but in a different orientation. The best orientation depends on how the data can be manipulated later on, which will be discussed later on however Row Vectors can always be transposed into Column Vectors and vice versa.

## Transposing

Transposing switches Rows and Columns and vice versa. This allows one to convert a Column Vector into a Row Vector and vice versa.

## Matrix – m by n Array (2D Array)

A matrix can be thought of as a rectangular grid of scalars.

A matrix can be considered as the building up of a row by use of equally sized column vectors:

Taking the example of using a column vector as a list of prices of goods in a shop. The first column could be Asda, the second Tescos, the thirds Morrisons, the fourth Lidl and the fifth Aldi's… for instance.

Alternatively it can be considered as the building up of a column by use of equally sized row vectors:

An example of a Matrix is also the screen of your computer or phone or the sense of the imaging CCD in your camera. It is a rectangular object with many pixels and you can think of the pixel as a square in the excel spreadsheet. My Dell XPS 13 9365 has 3200 by 1800 of these squares. For a black and white image to display each pixel has to give off a specified brightness. For 8 Bit there are 256 (0-255) levels of grey.

## Labelling Cells of a Matrix

Here the black line represents the boundary of the Matrix. By convention, we say the matrix has m rows by n columns often abbreviated a m by n matrix. In this case it is a matrix with 14 rows by 10 columns, known as a 14 by 10 matrix.

**Do not get the labelling mixed up when it comes to rows and columns. **

If it helps, think of entering a block of flats, and you are looking for apartment 4 by 2. In this case you are going to use the stairs to climb to the 4th floor (column) and then look for the 2nd apartment (row) on the 4th floor opposed to looking for the 2nd apartment on the 1st floor and then climbing up without using the stairs.

In a spreadsheet however the value at the top is 1 and you are moving down the way to get to the next row. Going back to the analogy of an apartment, think of entering a building on the first floor and the rest of the building being an underground bunker, so you enter on 1, go down to get to 2, go down again to get to 3 and so on and so forth.

This is an example of a 4 by 8 matrix and the highlighted cell is at position 3,7 i.e. row 3 and column 7.

## Pages – m by n by p Array (3D Array)

This may look more complicated but think of this like flicking through pages in a book, each page has the same dimensions in terms of m and n but p (the page) has changed. In this case, the sheets of the spreadsheet.

A colour image is an example of a 3D Array. Instead of there being a single grey channel, there are now three colour channels corresponding to the three primary colours red, green and blue. For 8 bit there are 256 levels (0-255). Any other colour can be made by mixing different values of these colours.

## n Dimensional Arrays

Higher dimensional arrays are possible. If we take the analogy of a 2D Array/Matrix being a gridded sheet of paper, and a book being a 3D Array. Then continuing the analogy, a single shelf containing multiple books would be a 4D Array. A single set of bookshelves would be a 5D Array. A library containing multiple bookshelves would be a 6D Array, a Council Containing multiple libraries would be a 7D Array and Country containing multiple Councils would be a 8D Array. I will not be looking into higher dimension arrays.