secons max number in a vector

조회 수: 1 (최근 30일)
PChoppala
PChoppala 2011년 11월 24일
Hi I need to find maximum and second maximum number in a vector. Can you please help?
For max, its max(X), but for second max I am unable to figure out.
Your help is appreciated
P

채택된 답변

Rick Rosson
Rick Rosson 2011년 11월 24일
a = max(X);
Y = X(X ~= a);
b = max(Y);
  댓글 수: 4
Walter Roberson
Walter Roberson 2011년 11월 25일
There are apparently efficient linear-time routines to find the N largest or N smallest numbers in a list, and supposedly they do not need to do a mini-sort of N elements to find the proper place in the list for each new value being tested. I have not yet been able to understand the logic in the paper that describes the internal comparison scheme.
Rick Rosson
Rick Rosson 2011년 11월 25일
Everyone makes mistakes. Glass houses...

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

추가 답변 (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