Converting cell arrays back to matrix

조회 수: 1 (최근 30일)
Stewart Tan
Stewart Tan 2019년 8월 7일
답변: madhan ravi 2019년 8월 7일
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?

답변 (1개)

madhan ravi
madhan ravi 2019년 8월 7일
cell2mat(mat_cell)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by