if i have array x and i want to get the index of maximum value of it ex:x=[1 2 3 4 5 0 11] i want command which give me that index of max(x)->7

 채택된 답변

Geoff
Geoff 2012년 3월 19일

0 개 추천

Use the find function:
indices = find(x == max(x));
There might be more than one maximum, so your output might be a vector. If you want just one value, use this:
index = find(x == max(x), 1);

댓글 수: 1

mohamed  al-asklany
mohamed al-asklany 2012년 3월 19일
i use this code in m-file and propet win and it is run but when i used it in embeeded func in simulink it gave me error

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 App Building에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by