Converting cell arrays back to matrix

1 visualizzazione (ultimi 30 giorni)
Stewart Tan
Stewart Tan il 7 Ago 2019
Risposto: madhan ravi il 7 Ago 2019
So i have a matrix:
my_mat = [10 5 6; 2 4 8; 1 20 50]
and i used the function 'num2cell' to convert the matrix above into a cell array
mat_cell = num2cell(my_mat)
which becomes:
{[ 10]} {[ 5]} {[ 6]}
{[ 2]} {[ 4]} {[ 8]}
{[ 1]} {[ 20]} {[ 50]}
but the problem I'm facing now is that i want to convert the cell array back to matrix so that i would get:
10 5 6
2 4 8
1 20 50
but i looked up on other post mentioning to use:
new_mat = [mat_cell{:}]
but I'm getting it in the form
1 2 10 20 4 5 50 8 6
Can anyone show me how i would get back the matrix form?

Risposte (1)

madhan ravi
madhan ravi il 7 Ago 2019
cell2mat(mat_cell)

Categorie

Scopri di più su Convert Image Type 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