필터 지우기
필터 지우기

Table with number of occurences

조회 수: 2 (최근 30일)
Noa Prasquier
Noa Prasquier 2021년 4월 19일
댓글: Walter Roberson 2021년 4월 19일
Hi,
I wrote a code that counts the number of occurences and I have to put it in a table with the alphabet as the first column. I can't figure out why the length of my vector is the same as the length of my string, and not as the length of the alphabet. The first 97 elements of vect_A were zeros (why?) so I suppose that this code won't work for a different string.
How can I create that table?
I would really appreciate if someone could correct my code and tell me what is wrong :
Here the code I tried :
s="In the golden lightning Of the sunken sun,Oer which clouds are bright'ning, Thou dost float and run, Like an unbodied joy whose race is just begun";
vect_A=[];
for letter=s(1:length(s));
letter=lower(letter);
for alphabet=['a':'z']
A=count(s,alphabet);
vect_A(alphabet)=A; %stock the value
end
end
B=(vect_A(97:end))'
C=array2table(B)
  댓글 수: 5
Noa Prasquier
Noa Prasquier 2021년 4월 19일
Okay so do you know how I can put the letters into the table ? The codes I tried didn’t work..
Walter Roberson
Walter Roberson 2021년 4월 19일
C.letters = ('a':'z').'

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

답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by