How can I concatenate a string array of a dimension 1x N into one cell
4 ビュー (過去 30 日間)
古いコメントを表示
Carlos Quispe Galdos
2022 年 7 月 12 日
コメント済み: Carlos Quispe Galdos
2022 年 7 月 12 日
Hello community,
I want to accomplish the following with my code:
- Originally I don't know the number of names in array A and I have to group them in just one cell concatenating them with the delimiter "/". I tried the for loop with no success and it is not necessary at all. Any hints on how I can accomplish this? I appreciate all the help.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1062315/image.jpeg)
1 件のコメント
Stephen23
2022 年 7 月 12 日
As well as JOIN() as Chunru showed here are a few other approaches:
A = {'ABC','DEF','HIJK'};
B = char(join(A,'/'))
C = sprintf('/%s',A{:});
C = C(2:end)
D = cell2mat(strcat('/',A));
D(1) = []
A(2,1:end-1) = {'/'};
E = [A{:}]
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!