![]() For example, accessing the element on the second row and third column: > M(2, 3) ![]() The most straight-forward method for accessing an element, is to specify its row-column index. These three methods are now explained in more detail using the following 3-by-3 matrix M as an example: > M = magic(3) Logical indexing - where you use a logical matrix (and matrix of true and false values) with the identical dimensions of the matrix you are trying to index as a mask to specify which value to return.That means, you specify each position in the matrix with a single number. Linear indexing - where the matrix is treated as a vector, no matter its dimensions.Subscript indexing - where you specify the position of the elements you want in each dimension of the matrix separately.MATLAB allows for several methods to index (access) elements of matrices and arrays:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |