Optimization on for loop and if statement
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
Is there any alternative way to improve these statements ?
for i = 1:telegramCount
for k = 1:calculationCount
if(telArray(i,1) == sortedArray(k,3))
firstPlace = k;
break;
end
end
end
Thanks in advance.
0 commentaires
Réponses (1)
Vladimir Sovkov
le 19 Nov 2019
firstPlace = find ( telArray(i,1) == sortedArray(:,3) ,1 )
replaces your entire "k" loop.
0 commentaires
Voir également
Catégories
En savoir plus sur Quadratic Programming and Cone Programming dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!