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

조회 수: 1 (최근 30일)
Armina Petrean
Armina Petrean 2023년 4월 5일
답변: Rik 2023년 4월 5일
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
Dyuman Joshi
Dyuman Joshi 2023년 4월 5일
To clarify, you want to plot the frequency graph for Upper case letters, lower case letters and digits individually from a given text?

댓글을 달려면 로그인하십시오.

채택된 답변

Rik
Rik 2023년 4월 5일
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개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by