Converting cell to 3 dimensional matrix

53 visualizzazioni (ultimi 30 giorni)
Pankaj
Pankaj il 25 Feb 2017
Commentato: Stephen23 il 22 Mar 2023
I have a cell of size [1, 50] each of it is 11 x 2 matrix.
I would like it to convert it to a 3-d matrix of size 11 X 2 X 50.
How it can be done? Cane it be done using reshape?
Thanks

Risposta accettata

Stephen23
Stephen23 il 25 Feb 2017
Modificato: Stephen23 il 25 Feb 2017
If C is your cell array:
cell2mat(permute(C,[1,3,2]))
or
cell2mat(reshape(C,1,1,[]))
or
cat(3,C{:})
  2 Commenti
Giovanni Bambini
Giovanni Bambini il 22 Mar 2023
And what if I want a50x11x2?
Stephen23
Stephen23 il 22 Mar 2023
"And what if I want a50x11x2?"
permute(cat(3,C{:}),[3,1,2])

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by