finding mode without any repeated number?

조회 수: 3 (최근 30일)
Md Moinuddin Shuvo
Md Moinuddin Shuvo 2018년 10월 12일
답변: Image Analyst 2018년 10월 12일
I am trying to find the Mode of the columns in the Matrix A. My problem is, if there is no similar value in the column, the mode function always returns the lowest possible number. I read the definition of Mode and if there is no number repeated then there should be no mode. In that case, I should be getting No mode or error message. But why do it gets me the lowest number in the column? What is the theory behind the mode() function here?
A=[1.13 2 9 ; 1.12 5 8; 1.17 7 6];
P= mode(A(:,1));
Q= mode(A(:,2));
R= mode(A(:,3));
The values that I get after running the code are -
P = 1.12
Q = 2
R =6

채택된 답변

Image Analyst
Image Analyst 2018년 10월 12일
"if there is no number repeated then there should be no mode" Where does it say that?
What I read, in the help for R2018b, is "When there are multiple values occurring equally frequently, mode returns the smallest of those values." So you have 3 modes, and it returns the smallest one, just as the help specifies.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by