Subscripting
Subscripts start at 1, not zero.
>> a = [1 2 3; 4 5 6; 7 8 9]
ans =
1 2 3
4 5 6
7 8 9
>> a(2,2)
ans =
5
A range of indices can be specified:
>> a(1:2, 2:3)
ans =
2 3
5 6
A colon indicates all subscripts in range:
>> a(:, 2:3)
ans =
2 3
5 6
8 9
Previous slide
Next slide
Back to first slide
View graphic version