This section explains how to use subscripting and indexing to access and assign values to the elements of a MATLAB matrix. It covers the following:
Accessing Single Elements
To reference a particular element in a matrix, specify its row and column number using the following syntax, where
A is the matrix variable. Always specify the row first and column second:
For example, for a 4-by-4 magic square
you would access the element at row 4, column 2 with
For arrays with more than two dimensions, specify additional indices following the
column indices. See the section on Multidimensional Arrays.
|Combining Unlike Data Types||Linear Indexing|
© 1994-2005 The MathWorks, Inc.