Convert a tridimensional array into a cell

1 visualización (últimos 30 días)
Sergio Alejandro Calderon Villanueva
Sergio Alejandro Calderon Villanueva el 17 de Feb. de 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

Respuestas (1)

Deepak Meena
Deepak Meena el 24 de Feb. de 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

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by