More efficient alternative to find()

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.

 Accepted Answer

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

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products

Release

R2021b

Tags

Community Treasure Hunt

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

Start Hunting!