speed up line: find(c>a(:,1) & c<= a(:,2))

조회 수: 1 (최근 30일)
Chaoyang Jiang
Chaoyang Jiang 2018년 3월 25일
댓글: Jan 2018년 3월 25일
How can I speed up this line:
a=[3 4; 5 6; 4 5;2 8; 1 9; 23 24;1 12;3 6;12 25; 15 30;...]
b=find(5>a(:,1) & 5<= a(:,2));
when size(a) is 100,000,000 *2, this line is super slow. Any idea?
Thank you!
  댓글 수: 6
David Fletcher
David Fletcher 2018년 3월 25일
In that case, I think shaving a few tenths off here and there isn't going to make much of a dent in your issue. Fundamentally, you are trawling through millions upon millions of elements hundreds of thousands of times. I've had little experience of the parallel toolbox, so I'm not sure if that could help in some way, but I suspect it would be like chucking chisels at Everest.
Jan
Jan 2018년 3월 25일
Then it is time to think twice: Is this approach efficient? Do you have any further information, which can be exploited, e.g. if the data is sorted, or the positions are near to the ones of the last iteration? A brute search is time-consuming in large data. There is no magic trick to reduce the time. Maybe you can parallelize the iterations?
I assume you can get more help, if you explain the actual problem and post the relevant code.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by