Converting cell arrays back to matrix

1 view (last 30 days)
Stewart Tan
Stewart Tan on 7 Aug 2019
Answered: madhan ravi on 7 Aug 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?

Answers (1)

madhan ravi
madhan ravi on 7 Aug 2019
cell2mat(mat_cell)

Categories

Find more on Convert Image Type 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!