필터 지우기
필터 지우기

combine number from cell array and letter to a string

조회 수: 4 (최근 30일)
Dongyan Zhu
Dongyan Zhu 2021년 6월 18일
댓글: Dongyan Zhu 2021년 6월 18일
Now I have a cell array contaning some numbers:
SequencePreview =
1×3 cell array
{'3'} {'1'} {'4'}
Then I want to get a string showed using for loop as below:
'V3-V1-V4'
Does someone have an idea? Thank you!

채택된 답변

Stephen23
Stephen23 2021년 6월 18일
편집: Stephen23 2021년 6월 18일
C = {'3','1','4'}
C = 1×3 cell array
{'3'} {'1'} {'4'}
S = join(strcat("V",C),"-") % output = string
S = "V3-V1-V4"
or the old-fashioned way:
S = sprintf('-V%s',C{:}); % output = char
S = S(2:end)
S = 'V3-V1-V4'

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by