More efficient alternative to find()

2 vues (au cours des 30 derniers jours)
Chun Hei Chan
Chun Hei Chan le 4 Août 2023
Commenté : Chun Hei Chan le 4 Août 2023
Hello,
I am working on some simulation data and I would like to find the maximum element in each randomly generated vector which has no inherent pattern. Is there any more efficient alternative to the find() function in this case since Profiler says that find() is taking up a significant proportion of the compile time.
Many thanks.

Réponse acceptée

John D'Errico
John D'Errico le 4 Août 2023
Modifié(e) : John D'Errico le 4 Août 2023
Why does max not do what you want? There are TWO returns from max.
X = randi(100,[1,10])
X = 1×10
56 1 14 16 99 73 73 55 89 95
[xmax,maxloc] = max(X)
xmax = 99
maxloc = 5
  1 commentaire
Chun Hei Chan
Chun Hei Chan le 4 Août 2023
Thanks for the tip!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Tags

Produits


Version

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by