Re: find()

3 次查看(过去 30 天)
John Kim
John Kim 2016-9-6
Dear all,
Hi, I have a question regarding find(). Does find() always return a vector containing the linear indices IN ASCENDING ORDER? I guess it does, but I cannot find documentation to that effect.
I'd much appreciate your help. Thanks very much!
Best,
John

回答(2 个)

George
George 2016-9-6
From what I can tell in the find documentation the answer is yes. The doc states that the find function "...returns the first n indices corresponding to the nonzero elements in X." (or if n is omitted it returns all of them)
The existence of the last directionallity argument further supports this by finding the last n elements.

Star Strider
Star Strider 2016-9-6
It does, at least as I read the documentation.
The relevant part of the find documentation is the Linear Indices section. A link at the end of that page points you to Matrix Indexing and specifically to the section on Linear Indexing. This section discusses the way MATLAB stores and indexes vectors and matrices.
Note that this relates specifically to linear indexing of vectors and matrices. The find function allows you to return the row and column indices of a matrix as well, so what you get as a result depends on what you ask for.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by