Efficiently find a value in a matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
Hey all,
So I have a simple 1D matrix that I'm trying to find a specific value in. I know of a way to do it, but my main question is if anyone knows of a more effcient way? As of current, I'm using as part of an operation that occurs on the order of millions or even billions of times, and using the matlab profiler it's told me that this is far and beyond the most inefficient part of the whole process.
This is how I currently do it...the third line take up ~60% of my run time
DummyData = [1,3,5,7,9];
ValueToFind = 3;
[~,Index] = min(abs(DummyDaya - ValueToFind));
댓글 수: 2
Stephen23
2021년 3월 26일
If you want to "find a specific value" why are you using code that just finds the closest value?
채택된 답변
weikang zhao
2021년 3월 27일
From the perspective of computational complexity, your code can no longer be optimized. You can seek help from GPU acceleration or parallel computing.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!