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]}

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by