![]() ![]() The individual indices are sometimes referred to as subscripts in Matlab documentation (see for example sub2ind). Pure multidimensional indexing specifies an index variable for each dimension of the array.An intermediate situation exists, which may be termed partially linear indexing: ![]() ![]() Indexing can be classified considering the following two attributes.Īccording to the number of dimensions each index variable refers to, indexing can be multidimensional or linear. This will be briefly discussed at the end. The description to follow focuses on indexing of numerical arrays, but it can be applied to cell arrays with either parenthesis or curly-brace indexing, with the obvious change of output type (cell array or comma-separated list, respectively). A good post on this is Essence of indexing by Loren Shure. A different question is how the shape ( size) of the output array is determined as a function of the shape of the index variables. This answer tries to clarify the different types of indexing and how they can be combined. Please let me know if there are more standard names than those I'm using. However, in some cases I've had to sort-of make up a name because I wasn't aware of an existing one. In the following I use terminology that I think is more or less in line with standard Matlab practice. What types of indexing are there in Matlab?.These examples (and more complicated ones that arise in practice) pose the following questions: In this expression, standard (integer-valued) indexing is used for the first coordinate, and logical indexing is used for the second. In fact, the logical index A>5 has the same effect as the linear index find(A>5).Īs a second example, consider > A = magic(3) This is logical indexing, right? But it also has some features of linear indexing, because a column vector is returned. However, sometimes there appears to be a blend between several of these forms. linear (using a single index to traverse an array with more than one dimension).Īt first sight, it may appear that these forms are exclusive: an index is either standard, or logical, or linear.standard (using integers along each dimension),.We are used to different forms of indexing in Matlab: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |