how to convert cell to double inside cell array

조회 수: 7 (최근 30일)
jaah navi
jaah navi 2021년 6월 23일
댓글: jaah navi 2021년 6월 23일
I am having A = 15×1 cell array
{2×1 double}
{2×1 double}
{2×1 double}
{2×1 double}
{2×1 double}
{2×2 cell }
{2×2 cell }
{2×2 cell }
{2×2 cell }
{2×2 cell }
{2×3 cell }
{2×3 cell }
{2×3 cell }
{2×3 cell }
{2×3 cell }
I want to convert the cell to double for A to display in the following manner
A = 15×1 cell array
{2×1 double}
{2×1 double}
{2×1 double}
{2×1 double}
{2×1 double}
{2×2 double }
{2×2 double }
{2×2 double }
{2×2 double }
{2×2 double }
{2×3 double }
{2×3 double }
{2×3 double }
{2×3 double }
{2×3 double }
  댓글 수: 1
Scott MacKenzie
Scott MacKenzie 2021년 6월 23일
A is a cell array of cell arrays. It might help if you show the code that generates or loads A, se we can see what is inside the cells within the cells of A.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2021년 6월 23일
mask = cellfun(@iscell, A);
A(mask) = cellfun(@cell2mat, A(mask), 'uniform', 0);
  댓글 수: 1
jaah navi
jaah navi 2021년 6월 23일
If i run the above command i am getting A = 15×1 cell array
{2×1 cell}
{2×1 cell}
{2×1 cell}
{2×1 cell}
{2×1 cell}
{2×2 cell}
{2×2 cell}
{2×2 cell}
{2×2 cell}
{2×2 cell}
{2×3 cell}
{2×3 cell}
{2×3 cell}
{2×3 cell}
{2×3 cell}
But actually i want to have A =
15×1 cell array
{2×1 double}
{2×1 double}
{2×1 double}
{2×1 double}
{2×1 double}
{2×2 double}
{2×2 double}
{2×2 double}
{2×2 double}
{2×2 double}
{2×3 double}
{2×3 double}
{2×3 double}
{2×3 double}
{2×3 double}

댓글을 달려면 로그인하십시오.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by