What is the faster mean to find a value of an array?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Abdulatif Alabdulatif
il 5 Mag 2014
Commentato: Image Analyst
il 7 Mag 2014
Hi all,
I am looking for the fastest search inside an array. For example A3 array has 6250 elements:
[i,j] = find(A3(:,1) == Total);
Total = A3(i,j+1);
This method takes about a minutes to decide if the value "Total" is in the array A3 or not! which is long time :(
Is there any solution for the problem?
Thanks : )
0 Commenti
Risposta accettata
Image Analyst
il 5 Mag 2014
Get a faster computer. Look at my results:
% Create sample array of 6250 elements
A3 = [randi(9, [1250,4]), ones(1250,1)];
numberOfElements = numel(A3)
Total = 8;
tic;
[i,j] = find(A3(:,1) == Total);
Total = A3(i,j+1);
toc
Elapsed time is 0.000033 seconds.
Is that 33 microseconds I'm getting? And you're getting minute(s)? Something doesn't add up.
12 Commenti
Image Analyst
il 7 Mag 2014
I have no ideas about SYM since I don't have that toolbox. Can you mark my Answer as "Accepted" now? Thanks.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Assumptions in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!