필터 지우기
필터 지우기

Is there a faster or alternative way to use find()?

조회 수: 10 (최근 30일)
Dc215905
Dc215905 2021년 10월 5일
댓글: Dc215905 2021년 10월 5일
I have two arrays.
size(A,2) = 525
size(B,2) = 4324438.
I'm trying to find the IDX of B that == A(i). I also have to round and take the first IDX just because of the time resolution of the data.
To achieve this I'm currently doing:
IDX =zeros(1,size(A,2));
for i = 1:size(A,2)
idxCueTemp = find(round(B(:),3)==round(A(i),3));
IDX(i) = idxCueTemp(1);
end
This is painfully slow and is taking ~60s to complete.
Is there a better way?
  댓글 수: 1
Matt J
Matt J 2021년 10월 5일
size(A,2) = 525
size(B,2) = 4324438.
Are size(A,1) and size(B,1) irrelevant for some reason?

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2021년 10월 5일
편집: Matt J 2021년 10월 5일
Br=round(B(:),3);
Ar=round(A);
[~,IDX]=ismember(Ar,Br);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by