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 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!