How to prevent cell array within cell array

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 件のコメント

Stephen23
Stephen23 2016 年 7 月 19 日
編集済み: Stephen23 2016 年 7 月 19 日
>> record = [{'school', 'class'}, name]
record =
'school' 'class' 'Tom' 'Tim'

サインインしてコメントする。

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 7 月 19 日

1 投票

It's simply
name = { 'Tom', 'Tim'};
record = [{'school', 'class'}, name]

1 件のコメント

Guillaume
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 件)

Andrei Bobrov
Andrei Bobrov 2016 年 7 月 19 日

0 投票

record = {'school', 'class', name{:}}
Star Strider
Star Strider 2016 年 7 月 19 日

0 投票

This works:
name = { 'Tom', 'Tim'};
record = {'school', 'class', name};
record2 = {record{1:2}, record{3}{1:2}};
record2 =
'school' 'class' 'Tom' 'Tim'

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by