A matrix can be entered in different ways:
A matrix element can consist of all MATLAB elements. For example, the command:
- Between [ and ], where the rows are separated by a semicolon, and the elements are separated by spaces or commas. For example:
>> A = [1 2 3;4 5 6;7 8 9]
>> A = [1,2,3;4,5,6;7,8,9]
- Between [ and ], where every row starts on a new line and the elements are separated by spaces or commas. For example:
>> A = [1 2 3
4 5 6
7 8 9]
- Via external files in which the values of the variables are stored or are being calculated.
>> a = [-1.3 sqrt(3) (1+2+3)*4/5]
You can also build a matrix out of other matrices to form a new matrix. For example,
C = [A;a]
When doing this, the sizes of the matrices have to be compatible!