About the use of find
조회 수: 2 (최근 30일)
이전 댓글 표시
I want to detect values greater than 10 and get their indices.
In my case, I'm using find to get the index as follows.
y = find( x > 10 );
I think find is finding the value greater than 10 in all elements of x and getting the index.
So I have a question.
Does find start computing at the moment when all the elements of x are given, rather than at the moment when any element of x is given?
I would like to perform the computation at the moment when even one element of x is given, do the same process as find, get the same index, and store it in the same way.
In that case, what kind of program should I write? It would be great if you could post your program.
답변 (1개)
Wan Ji
2021년 8월 23일
Find is not at all faster than logical inices.
IF you know how to use logical indices to get elements from matrix. I believe you will like it.
A = [true, false, true, false]; % logical inices
B = [4,3,5,6];
B(A) % this gets the value in B corresponds to true element in A
Then
ans =
4 5
But find should have such a following process
p = find(A);
B(p)
Also,
ans =
4 5
Find sometimes can be implemented by
n = 1:1:length(A);
p = n(A)
Then
p =
1 3
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!