Linear Indexing

A linear indexing expression is one that uses a single subscript to index a matrix or higher-dimensional array. To illustrate the concept we will use a 4 X 4 Hilbert matrix as an example:

Example

>> Z = hilb(4)

Z =

    1.0000    0.5000    0.3333    0.2500
    0.5000    0.3333    0.2500    0.2000
    0.3333    0.2500    0.2000    0.1667
    0.2500    0.2000    0.1667    0.1429

>> Z([3,9])

ans =

    0.3333    0.3333

For illustrating concept, the above matrix is represented as :

>> Z = hilb(4)

Z =

    1.0000(1)    0.5000(5)    0.3333(9)     0.2500(13)
    0.5000(2)    0.3333(6)    0.2500(10)    0.2000(14)
    0.3333(3)    0.2500(7)    0.2000(11)    0.1667(15)
    0.2500(4)    0.2000(8)    0.1667(12)    0.1429(16)

Here you can see that Z ( [3 9]) extracts the 3rd and 9th elements of Z.