Vector and matrix element access: Difference between revisions

From iMath
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
Line 1: Line 1:
Elements of [[vector|vectors]] and [[matrix|matrices]] can be accessed in two ways: With the [[function|mindex function]] and with angular brackets <code>[ ]</code>.  
Elements of [[vector|vectors]] and [[matrix|matrices]] can be accessed in two ways: With the [[function|mindex function]] and with angular brackets <code>[ ]</code>.  
* <code>[ [[expression]] ]</code> accesses an element of a vector. Indexes start at 1.
* <code>[ [[expression]] ]</code> accesses an element of a vector. Indexes start at 1.
* <code>[ [[expression]] , [[expression]] ]</code> accesses an element of a matrix. Indexs start at 1, and the first index is the row number. Either of the expressions can be replaced by an asterisk <code>*</code>, then the whole row or column will be returned as a vector.
* <code>[ [[expression]] , [[expression]] ]</code> accesses an element of a matrix. Indexes start at 1, and the first index is the row number. Either of the expressions can be replaced by an asterisk <code>*</code>, then the whole row or column will be returned as a vector.


[[Category:Element]]
[[Category:Element]]

Latest revision as of 14:10, 27 September 2026

Elements of vectors and matrices can be accessed in two ways: With the mindex function and with angular brackets [ ].

  • [ expression ] accesses an element of a vector. Indexes start at 1.
  • [ expression , expression ] accesses an element of a matrix. Indexes start at 1, and the first index is the row number. Either of the expressions can be replaced by an asterisk *, then the whole row or column will be returned as a vector.