How to prevent cell array within cell array

13 次查看(过去 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

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2016-7-19
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
record = {'school', 'class', name{:}}

Star Strider
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'

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by