Convert a tridimensional array into a cell

1 vue (au cours des 30 derniers jours)
Sergio Alejandro Calderon Villanueva
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

Réponses (1)

Deepak Meena
Deepak Meena le 24 Fév 2021
Hi Sergio,
You can use num2cell.
>> 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

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by