Question about ismember replacements
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello, thanks for reading this,
I have a question about a very timely procedure in a MATLAB script I have. Something I have to do repeatedly is check for point indices in a global matrix, and my repetitive calls are getting to be very costly time-wise.
A rough snippet of the code I have is:
l2 = ismember(randomgen_ptmx,bifPt, 'rows');
[maxval,ind] = max(l2);
counter = 1;
for i=1:length(randomgen_connMx)
if ind == randomgen_connMx(i,1)
dag(counter) = i;
counter = counter+1;
end
end
where bifPt is a 1x3 array, and randomgen_ptmx is a nx3 matrix. What I do in the first three lines is search for the index of the big point as it exists in the randomgen_ptmx matrix, then I take that index and dearch for where it is the first entry in a n1x2 matrix (randomgen_connMx).
So, a simple explanation is I want to see where the index of bifPt in the global matrix randomgen_ptmx is in the first column entry of randomgen_connMx. I check for this in a ismember function, but when I profiled my code my repetitive calls to ismember is by far the biggest time waste I have. Are there better ways to do this?
Thanks a lot for your advice!
댓글 수: 0
채택된 답변
추가 답변 (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!