finding most common letter in a string

6 vues (au cours des 30 derniers jours)
Max
Max le 12 Nov 2015
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'

Réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 12 Nov 2015
Modifié(e) : Azzi Abdelmalek le 12 Nov 2015
y='asdqwdqwdasasdasdaasasdwdqwd'
[ii,jj,kk]=unique(y)
a=accumarray(kk,1)
idx=a==max(a)
out=ii(idx)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by