Arrays and Matrices

In programming, an array is a data structure that holds a collection of elements, which can be of any data type (such as numbers, strings, boolean, or objects). The elements in an array can be accessed using an index number starting from 0 or 1, depending on the programming language.

A matrix is a 2D array, which means it is an array of arrays. The row and column indexes allow access to each matrix element.

Arrays and matrices in MATLAB and Python

One of the unique features of MATLAB is that any 1D variable initialized in MATLAB is a 1×11\times1 matrix. Let’s have a look at how we initialize an array and matrix in different ways.

For MATLAB, the array and matrix are the same. The array is a matrix with either one row and multiple columns or multiple rows with one column.

Get hands-on with 1400+ tech skills courses.