count occurences and create a table

2 ビュー (過去 30 日間)
Noa Prasquier
Noa Prasquier 2021 年 4 月 11 日
コメント済み: Noa Prasquier 2021 年 4 月 12 日
Hi,
I want to count the nu;ber of occurences of each letter in my string and put the values in a table. I can't figure out how to create a vector with my A values or directly put the values in a table.
here's my code :
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";
for letter=s(1:length(s));
letter=lower(letter);
for alphabet=['a':'z']
A=count(s,alphabet);
array2table(A)
end
end
The output is a table for each value of A
A is an integer instead of a vector

回答 (1 件)

Cris LaPierre
Cris LaPierre 2021 年 4 月 11 日
You have to assign array2table to something if you want to capture it.
You have to use indexing to capture the result from each loop as well.
Perhaps ch 13 in MATLAB Onramp can show you how to use indexing to capture the result of each loop.
  1 件のコメント
Noa Prasquier
Noa Prasquier 2021 年 4 月 12 日
ok, I'll try this, thank you!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by