counting How many times a letter apear in a notepad text?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a rather large text in a notepad and I want to find out how many times a certain letter is repeated in it.For example, I want to know how many times all the letters of the alphabet appears in that text and then I want to plot it, to show me something like that .
but the text is pretty big. it is a reference corpus. ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1345869/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1345869/image.png)
8 commentaires
Dyuman Joshi
le 5 Avr 2023
To clarify, you want to plot the frequency graph for Upper case letters, lower case letters and digits individually from a given text?
Réponse acceptée
Rik
le 5 Avr 2023
txt = 'The quick broWn fox jUmps oVer the lazy dog 1 2 3 4 5 6 7 8 9 0';
Edges = double(['a':'z' 'A':'Z' '0123456789']) + [-0.5;0.5];
Edges = unique(Edges(:));
histogram(double(txt),Edges)
I will leave setting the XTickLabels for you. You can also use histcounts instead and create a bar graph with its output (so you can skip the values between 'Z' and 'a').
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Annotations 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!