Basics

14. Matrix

We can input a matrix elements by leaving a space between elements, or separating the elements with a comma as below. We can end a row by typing the elements in the next row by pressing enter key. Row can also be ended by using semicolon.
>> A = [1 2 -2
2 -1 0]
 
A =

     1     2    -2
     2    -1     0

>> A = [1,2,-2
2,-1,0]
 
A =

     1     2    -2
     2    -1     0

>> A = [1 2 -2; 2 -1 0]
 
A =

     1     2    -2
     2    -1     0