【发布时间】:2015-06-25 04:11:04
【问题描述】:
我需要输入带有大写字母的句子,然后将句子拆分为单词,并为每个单词计算字符“a”的数量
我做了这个
clear
sentences=input('Write your sentences: ','s');
low=lower(sentences);
disp('Sentences splitted to words: ');
words=regexp(low,' ','split');
for i=1:length(words)
disp(words(i))
end
现在我不知道如何计算拆分后每个单词中的字符'a',因为这些单词被转换为单元格。 有人可以帮我解决这个问题吗?
【问题讨论】:
-
从文档这里开始:Characters and Strings
-
标题中无需人为插入标签;理想情况下,标题应该是连贯的句子
标签: matlab