how to convert cell to double inside cell array
1 次查看(过去 30 天)
显示 更早的评论
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
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
2021-6-23
mask = cellfun(@iscell, A);
A(mask) = cellfun(@cell2mat, A(mask), 'uniform', 0);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!