>> A = [3, 5, -2, 7, 0.9]; >> A[3] -2The index itself can be vector such that a bunch of the elements of A are referenced.
>> A = [3, 5, -2, 7, 0.9]; >> A[[1, 3, 5]] 3 -2 0.9 >> A[1:3] 3 5 -2 >> A[1 : 2 : 5] // 1 : 2 : 5 is the same as [1, 3, 5] 3 -2 0.9The dollar sign $ when used as an index, is the largest value of the index, therefore A[$] is the last element of A.
>> A = [3, 5, -2, 7, 0.9]; >> A[$] 0.9 >> A[3:$] -2 7 0.9
If matrix A is not a vector, then the element referred to by A[k] is the k-th element of the row vector obtained by horizontally joining all the rows of A.
>> A = [1,4, 9; 2, 3, 5; -2, 5, 10] 1 4 9 2 3 5 -2 5 10 >> A[5] 3 >> A[9] 10