How to convert "cell array" to "character array"
537 次查看(过去 30 天)
显示 更早的评论
How to convert {'A1'} {'B1'} {'C1'} to 'A1' 'B1' 'C1'
0 个评论
回答(3 个)
Jonas
2021-7-8
the format 'A1' 'B1' 'C1' is not possible with character array, but 'A1B1C1' is possible:
asCell={'A','B','C'}; charArray=[asCell{:}]
0 个评论
DGM
2021-7-8
编辑:DGM
2021-7-8
It's kind of hard to tell what exactly you want, since your example isn't really proper syntax.
If you just have a scalar cell array with a char vector:
A = {'potato'};
B = A{:}
If you have a cell array with multiple elements, each containing a char, the answer depends on whether all the char vectors are the same size and what you expect the output to look like.
A = {'potato' 'tomato' 'grapes'};
vertcat(A{:}) % only works if they're all the same size
horzcat(A{:})
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!