Expand a matrix:
To expand a matrix, an individual element could not be added as that would mean there would no longer be the similar number of values in every row.
Though, the whole row or column could be added. For illustration, the following would add a fourth column to the matrix:
>> mat(:,4) = [9 2]'
mat =
2 11 4 9
5 6 7 2
Now as we saw with vectors, if there is a gap between the present matrix and the row or column being added, the MATLAB will fill in with zeros.
>> mat(4,:) = 2:2:8
0 0 0 0
2 4 6 8