Refer the subset of a matrix:
It is also possible to refer to the subset of a matrix. For illustration, this refers to the first & second rows, second & third columns:
>> mat(1:2,2:3)
ans =
3 4
4 5
Using a colon for the row index means that all rows, regardless of how many, and using a colon for the column index means that all columns. For illustration, this refers to the whole first row:
>> mat(1,:)
ans =
2 3 4
and this refers to the whole second column:
>> mat(:, 2)
ans =
3
4