%%
任意给出一个英语句子,请提取出其中的单词,并设计一个结
构,其域有
Name
,
No
,
length
,
value
,分别用于存储每个单
词的名称、居中序号、单词长度、单词各字符的
ASCII
码之
和。
txt=
'Millions of engineers and scientists worldwide use MATLAB to analyze and design the
systems and products transforming our world.'
;
sen=strsplit(txt);
for
i=1:length(sen)
Name(i)=sen(i);
No(i)=i;
Length(i)=length(cell2mat(sen(i)));
Value(i)=sum(double(sen{i}));
end
s=struct(
'Name'
,Name,
'No'
,num2cell(No),
'Length'
,num2cell(Length),
'Value'
,num2cell(Value))
s = 1×19 struct array with fields: