Question about ismember replacements
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!