Convert a tridimensional array into a cell
4 views (last 30 days)
Show older comments
Sergio Alejandro Calderon Villanueva
on 17 Feb 2021
Commented: Sergio Alejandro Calderon Villanueva
on 27 Feb 2021
I have the following problem: I need to convert an array A wit dimensions 4x4x5 into a cel 4x4 where ecah entry is 1x5 using mat2cell or an abrreviated method. I appreciate your help
0 Comments
Answers (1)
Deepak Meena
on 24 Feb 2021
Hi Sergio,
>> a = ones(4,4,5);
>> p = num2cell(a,3);
>> p
p =
4×4 cell array
{1×1×5 double} {1×1×5 double} {1×1×5 double} {1×1×5 double}
{1×1×5 double} {1×1×5 double} {1×1×5 double} {1×1×5 double}
{1×1×5 double} {1×1×5 double} {1×1×5 double} {1×1×5 double}
{1×1×5 double} {1×1×5 double} {1×1×5 double} {1×1×5 double}
But the size of the cell won't be 1x5 , it would be 1x1x5
Thanks
See Also
Categories
Find more on Cell Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!