Concatenate nested cell array in one

6 次查看(过去 30 天)
Hello matlab community,
how do I concatenate arrays with different sizes into one dimensional array:
Example
dblArrayX{1}{1} = [12;15];
dblArrayX{2}{1} = 13;
dblArrayX{3}{1} = [16;17;19];
unknown method leads to
newArray{1} = [12;15;13;16;17;19]
I need the method for this newArray without loops.
  6 个评论
Rik
Rik 2020-5-26
Can you edit your question so it contains the actual shape of your data?
Mate D
Mate D 2020-5-28
编辑:Mate D 2020-5-28
The data is in exact format as the example. Do not know why, but it works with the method you presented (and deleted) earlier:
cell2mat(cellfun(@(X) X{1},tmpMdlParamsValues','UniformOutput',false))

请先登录,再进行评论。

采纳的回答

Rik
Rik 2020-5-28
Since apparently it was the correct solution, I'll repost it:
It puzzles me why you would want this without the temporary variable. Putting it on one line is of course trivial. The code below should do what you need.
newArray{1}=cell2mat(cellfun(@(x) x{1},dblArrayX','UniformOutput',false));

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Operators and Elementary Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by