Creating Matrix Variables:
Creating a matrix variable is actually just a generalization of creating a row and column vector variables. That is, the values within the row are separated by either commas or spaces, and the various rows are separated by the semicolons. For illustration, the matrix variable mat is created by explicitly typing the values:
>> mat = [4 3 1; 2 5 6]
mat =
4 3 1
2 5 6
There should always be similar number of values in each row. If you try to generate a matrix in which there are various numbers of values in the rows, the outcome will be an error message; for illustration:
>> mat = [3 5 7; 1 2]
??? Error using ==> vertcat