I want to print the dot number that contains the text character.

1 次查看(过去 30 天)
clear
clc
NN = str2mat('s23;s24');
for i = 1:2
name{i}= sprintf('%d. Point', NN(i))
end
I tried something like that but I could not do it.

采纳的回答

Walter Roberson
Walter Roberson 2018-2-20
编辑:Walter Roberson 2018-2-20
NN_split = strsplit(NN, ';');
for i = 1 : 2
name{i} = sprintf('%s. Point', NN_split{i});
end
Mind you, I would not have initialized NN that way in the first place unless there was good reason to:
NN = {'s23', 's24'};
for i = 1 : 2
name{i} = sprintf('%s. Point', NN{i]);
end
or more simply
NN = {'s23', 's24'};
name = strcat(NN, '. Point');
with no loop.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by