More efficient alternative to find()

조회 수: 6 (최근 30일)
Chun Hei Chan
Chun Hei Chan 2023년 8월 4일
댓글: Chun Hei Chan 2023년 8월 4일
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.

채택된 답변

John D'Errico
John D'Errico 2023년 8월 4일
편집: John D'Errico 2023년 8월 4일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by