필터 지우기
필터 지우기

Problems with the Mode function

조회 수: 6 (최근 30일)
PAK
PAK 2019년 1월 5일
댓글: PAK 2019년 1월 5일
Hi Everyone,
Happy New Year!
I'm having problems with the "mode" function in Matlab 2018a. I have a 1x1979253 single "x", where Matlab calculates the mode as 36.1455.
However, when I quick check to make sure that makes sense by putting my values into a histogram, it is very clear the mode should be in the 60s, which also is where I was expecting it to be.
Any ideas what could be causing this? I've attached the histogram for reference.LFP_Frequencies.jpg
Thanks!
PAK
y = mode(x,2);
histogram(x);

채택된 답변

Image Analyst
Image Analyst 2019년 1월 5일
We're not sure how you plotted that. Are you sure that the x axis are the actual values of your data, and not just the bin numbers? Did you do
[counts, edges] = histcounts(data);
bar(counts);
or did you do
bar(edges(1:end-1), counts);
Are you sure that it's bin 60 that is the highest and bin 60 contains values from 32 to 35 or something?
  댓글 수: 1
PAK
PAK 2019년 1월 5일
Hi,
Sorry about this question, I think I figured out the issue just now.
Rounding to two significant figures before using mode sorted out this issue.
Thanks for pointing out the plotting issue, I didn't think abou the bin count/actual data issue. I will incorporate that into my analysis as well!
Cheers,
PAK

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by