How To Create A Matrix In Matlab

To create a matrix in Matlab, we can store the matrix inside a square bracket “[]”, with each row within the matrix separated by a semicolon “;”.

For instance, let’s say I wanted to create a 3×3 matrix with the values 1 – 9.

Then the code should look something like this below:

matrix = [1 2 3; 4 5 6; 7 8 9]