finding most common letter in a string

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'

Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 12 Nov. 2015
Bearbeitet: Azzi Abdelmalek am 12 Nov. 2015

0 Stimmen

y='asdqwdqwdasasdasdaasasdwdqwd'
[ii,jj,kk]=unique(y)
a=accumarray(kk,1)
idx=a==max(a)
out=ii(idx)

Kategorien

Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange

Gefragt:

Max
am 12 Nov. 2015

Bearbeitet:

am 12 Nov. 2015

Community Treasure Hunt

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

Start Hunting!

Translated by