Convert numerical label Vector to char label
2 次查看(过去 30 天)
显示 更早的评论
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].
0 个评论
采纳的回答
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 = strtrim(sprintf(' %s ',b{:}))
% 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 = strtrim(sprintf(' %s ',b))
EDIT — (4 Jun 2022 at 2:48)
.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!