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

1 回表示 (過去 30 日間)
Muhendisleksi
Muhendisleksi 2018 年 2 月 20 日
編集済み: Walter Roberson 2018 年 2 月 20 日
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.
  2 件のコメント
Walter Roberson
Walter Roberson 2018 年 2 月 20 日
For the cases i=1 and i=2 what would your desired output be?
Muhendisleksi
Muhendisleksi 2018 年 2 月 20 日
編集済み: Walter Roberson 2018 年 2 月 20 日
i=1 >>> s23. Point
i=2 >>> s24. Point

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

採用された回答

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 Center および File ExchangeEnvironment and Settings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by