필터 지우기
필터 지우기

Can I use mode for nominal data to calculate most frequent values

조회 수: 1 (최근 30일)
Tania
Tania 2014년 7월 22일
댓글: Star Strider 2014년 7월 23일
Hey! Is it possible to use mode for nominal data or is there something similar I could use to count my nominal data? Eg. I have tree tree apple . Then it should say tree: 2 times; apple: 1
Thank you!

채택된 답변

Star Strider
Star Strider 2014년 7월 22일
This works, although it requires the Statistics Toolbox:
X = categorical({'tree' 'tree' 'apple'});
[K,I] = hist(X)
producing:
K =
1.0000e+000 2.0000e+000
I =
'apple' 'tree'
  댓글 수: 2
Tania
Tania 2014년 7월 23일
Thank you! the first line makes sense to me, but I dont understand what the [K,I] & the hist(X) does? Thank you!
Star Strider
Star Strider 2014년 7월 23일
My pleasure!
The outputs K and I (arbitrary names) return the counts in K and the names in I of the contents of X that is in this instance a categorical cell array of strings. The Statistics Toolbox implenemtation of hist (histogram counts) for categorical data, counts the occurrences of each category and displays the corresponding names if you want them.

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

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