Find index of maximum number

조회 수: 1 (최근 30일)
Nyan Wai Lin
Nyan Wai Lin 2012년 4월 6일
Hi,
May I know how to write in MATLAB to find the index of maximum number.
M = 13;
[gh_w, ph_w, d_l, pl_d] = getWindData(M, weekday);
maxIndex = max (gh_w(:,M));
H = maxIndex;
I only got the output of maximum value which is 611.5077. Thank.

채택된 답변

John D'Errico
John D'Errico 2012년 4월 6일
Read the help for max (always a good thing to read the help!)
What does it say?
  댓글 수: 2
Nyan Wai Lin
Nyan Wai Lin 2012년 4월 6일
hi, yes I used to read help.
I knew that "max" give maximum value.
now it seems that i've assigned to maxIndex.
But I try to find in google.
The code use maxIndex to find the index of maximum value.
For example:
sortedValues = unique(A(:)); %# Unique sorted values
maxValues = sortedValues(end-4:end); %# Get the 5 largest values
maxIndex = ismember(A,maxValues);
Oleg Komarov
Oleg Komarov 2012년 4월 6일
If you need only THE maximum, then read the help (again and paying attention to the second output).
If you need to determine the first N maximum numbers and their position, then ask the question accordingly.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by