Contents Previous Next Subchapters Current Chapters-> vectorelem matrixelem rowcol seqrowcol seqsubvec subblock nonseq vecind endexp base colbase rowbase Parent Chapters-> Omatrix6 submatrices endexp Search Tools-> contents reference index search

Using End As An Index Value
 Syntax vector`(`exp```:end) ```matrix`(`exp`, `exp```:end) ```matrix`(`exp`:end, `exp`)` See Also vector indices , non-sequential access

Description
When the keyword `end` is used as part of an index expression , it refers to the maximum index in the vector or matrix being referenced.

Tutorial

One Index
You can use `end` when only one index is specified. If you enter ```      x = {5., 4., 3., 2.}      x(2 :: end) ``` O-Matrix will respond ```      {      4      3      2      } ``` If you continue by entering ```      x(1 :: end - 1) ``` O-Matrix will respond ```      {      5      4      3      } ``` You can also use `end` when assigning a value to a subvector. If you continue by entering ```      x = x'      x(end - 1 :: end) = [0, 0]      print x ``` O-Matrix will respond ```      [ 5 , 4 , 0 , 0 ] ```
Two Indices
You can also use `end` when two indices are specified. If you enter ```      x     = {[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]}      x(2::end, :) ``` O-Matrix will respond ```      {      [ 5 , 6 , 7 , 8 ]      [ 9 , 10 , 11 , 12 ]      } ``` If you continue by entering ```      x(:, 1 :: end - 2) ``` O-Matrix will respond ```      {      [ 1 , 2 ]      [ 5 , 6 ]      [ 9 , 10 ]      } ``` If you then enter ```      x(2 :: end, 1 :: end - 2) ``` O-Matrix will respond ```      {      [ 5 , 6 ]      [ 9 , 10 ]      } ``` ``` ```You can also use `end` when assigning a value to a submatrix. If you continue the previous example by entering ```      x(end - 1 :: end, end - 1 :: end) = {[0, 0], [0, 0]}      print x ``` O-Matrix will respond ```      {      [ 1 , 2 , 3 , 4 ]      [ 5 , 6 , 0 , 0 ]      [ 9 , 10 , 0 , 0 ]      } ```