Convert nested cell array into single cell array

8 ビュー (過去 30 日間)
Mausmi Verma
Mausmi Verma 2021 年 12 月 22 日
コメント済み: Mausmi Verma 2021 年 12 月 26 日
I am getting variable value in workspace in the form of nested cell array
A={{[1] [2] [3]} {[4] [5] [6]}}
but i want answer in the form of single cell array as,
B={[1 2 3] [4 5 6]}
please help

採用された回答

Voss
Voss 2021 年 12 月 22 日
編集済み: Voss 2021 年 12 月 22 日
A = {{[1] [2] [3]} {[4] [5] [6]}};
B = cellfun(@(x)[x{:}],A,'UniformOutput',false);
display(A);
A = 1×2 cell array
{1×3 cell} {1×3 cell}
display(B);
B = 1×2 cell array
{[1 2 3]} {[4 5 6]}
  1 件のコメント
Mausmi Verma
Mausmi Verma 2021 年 12 月 26 日
Exactly what i needed , thanks a lot

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by