How to prevent cell array within cell array
3 ビュー (過去 30 日間)
古いコメントを表示
Dear Experts
I have two cell arrays. One cell array is a combination of another cell array.
name = { 'Tom', 'Tim'};
record = {'school', 'class', name};
Output becomes nested cell arrays. Desired Output:
record = {'school', 'class', 'Tom', 'Tim'}
Thank you for your help
1 件のコメント
採用された回答
Azzi Abdelmalek
2016 年 7 月 19 日
It's simply
name = { 'Tom', 'Tim'};
record = [{'school', 'class'}, name]
1 件のコメント
Guillaume
2016 年 7 月 19 日
Of all, the answers here, this is the most appropriate. What is being asked is simply the concatenation of two cell arrays.
So:
x = [cellarray1, cellarray2];
その他の回答 (2 件)
Star Strider
2016 年 7 月 19 日
This works:
name = { 'Tom', 'Tim'};
record = {'school', 'class', name};
record2 = {record{1:2}, record{3}{1:2}};
record2 =
'school' 'class' 'Tom' 'Tim'
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Cell Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!