how to convert cell to double inside cell array

3 Ansichten (letzte 30 Tage)
jaah navi
jaah navi am 23 Jun. 2021
Kommentiert: jaah navi am 23 Jun. 2021
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 Kommentar
Scott MacKenzie
Scott MacKenzie am 23 Jun. 2021
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 23 Jun. 2021
mask = cellfun(@iscell, A);
A(mask) = cellfun(@cell2mat, A(mask), 'uniform', 0);
  1 Kommentar
jaah navi
jaah navi am 23 Jun. 2021
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}

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Types finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by