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.
  댓글 수: 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 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