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 Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by