finding most common letter in a string

조회 수: 12 (최근 30일)
Max
Max 2015년 11월 12일
편집: Azzi Abdelmalek 2015년 11월 12일
say I have a string y='asdqwdqwdasasdasdaasasdwdqwd' How do I find the letter that occurs the most in y which is clearly 'a' so have something like mostcommonletter='a'

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2015년 11월 12일
편집: Azzi Abdelmalek 2015년 11월 12일
y='asdqwdqwdasasdasdaasasdwdqwd'
[ii,jj,kk]=unique(y)
a=accumarray(kk,1)
idx=a==max(a)
out=ii(idx)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by