counting How many times a letter apear in a notepad text?

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.

8 Comments

This. BUT it doesn't take the whole text but only a piece of it. AND I NEED FOR ALL THE TEXT WHICH IS LARGER
But fileread returns the entire text file. What gives you the impression that something is missing?
when I change to lower case it gives me the same thing
and I want to do this for both types of letters and maybe also for numbers.
To clarify, you want to plot the frequency graph for Upper case letters, lower case letters and digits individually from a given text?

Sign in to comment.

 Accepted Answer

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').

More Answers (0)

Categories

Products

Release

R2020a

Asked:

on 5 Apr 2023

Answered:

Rik
on 5 Apr 2023

Community Treasure Hunt

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

Start Hunting!