Converting char array into string cells
1 回表示 (過去 30 日間)
古いコメントを表示
How can i convert my array into different string cells Array=[0, 1,3,0] I used Cells=cellstr(num2str(array) ) And i got 1×1 cell {'0 1 3 0' } I want my cell to be 1×4(or 1×any number) {'0','1','3','0'} Please help
0 件のコメント
採用された回答
Cris LaPierre
2021 年 1 月 8 日
This creates a 1x4 cell array
Array = [0, 1,3,0];
A = num2cell(Array);
C = cellfun(@num2str,A,'UniformOutput',false)
3 件のコメント
その他の回答 (1 件)
Steven Lord
2021 年 1 月 8 日
Rather than creating a cell array containing char vectors, why not create a string array?
x = [0 1 3 0];
s = string(x)
three = s(3)
threeChar = s{3}
whos
I'm not 100% sure that indexing with curly braces to create a char vector was supported in release R2018b but if it wasn't calling char on the string array would work.
参考
カテゴリ
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!