Hello,I want to convert a to b please a=[1 1 2 1 3 1 3 2] To b=[as as be as ce as ce be].

 채택된 답변

Star Strider
Star Strider 2022년 6월 4일
편집: Star Strider 2022년 6월 4일
Try this —
map = {'as','be','ce'}; % Cell Array
a=[1 1 2 1 3 1 3 2];
b = map(a)
b = 1×8 cell array
{'as'} {'as'} {'be'} {'as'} {'ce'} {'as'} {'ce'} {'be'}
b = strtrim(sprintf(' %s ',b{:}))
b = 'as as be as ce as ce be'
% To b=[as as be as ce as ce be].
map = ["as","be","ce"]; % String Array
a=[1 1 2 1 3 1 3 2];
b = map(a)
b = 1×8 string array
"as" "as" "be" "as" "ce" "as" "ce" "be"
b = strtrim(sprintf(' %s ',b))
b = 'as as be as ce as ce be'
EDIT — (4 Jun 2022 at 2:48)
Added sprintf and strtrim calls.
.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

질문:

2022년 6월 4일

편집:

2022년 6월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by