If we wanted to store the entire first row of A in the variable firstrow, we would say that we want “all four columns of the first row.” This suggests that we can use the colon operator to shorten our work. This means that we can think of 7 as being located in the 6th entry, or:įor completeness, in the last example, if we think of A as a matrix:Ī(1,1) = 1 A(1,2) = 2 A(1,3) = 3 A(1,4) = 4Ī(2,1) = 5 A(2,2) = 6 A(2,3) = 7 A(2,4) = 8
But, it is crucial to realize that we count elements in this way using a “column precedence.” This means that we count, one at a time, down the columns. Second, we can think of 7 as being one of the eight elements total. First, we can think of the 7 as being located in the second row and third column. Suppose we wanted to isolate the 7 in the matrix A and store it as the variable temp.
There are actually two ways to view this matrix, either as a rectangular array of 2 rows and 4 columns, or as a list of 8 elements.