How can we find out no of max values in a matrix

조회 수: 1 (최근 30일)
navan
navan 2015년 5월 5일
답변: Titus Edelhofer 2015년 5월 5일
I have a matrix A= [1 2 3 4 9 9 9 9 3 2]. I want to know how can i find out the total number of max. value in the same matrix(which is 9). I have used max(A), but it gives only one value 9, but need get the total number of 9 values ,( which is 4).kindly help.

채택된 답변

Titus Edelhofer
Titus Edelhofer 2015년 5월 5일
Hi Navan,
count them:
n = sum(A == max(A));
Note though, that this works fine for integers, but if you have floating point, you need to replace the "==" by abs(A-max(A)) < tol with some tolerance tol.
Titus

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by