How to convert from a matrix to a cell?

2 次查看(过去 30 天)
Given matrix is
A=[1 2 3 4 5 6 7 8; 9 10 11 12 13 14 15 16];
and output is
B={[1 2 3 4],[5 6 7 8];[9 10 11 12],[13 14 15 16]};
How can I do that?

采纳的回答

Star Strider
Star Strider 2020-7-17
Use the mat2cell function:
A=[1 2 3 4 5 6 7 8; 9 10 11 12 13 14 15 16];
B = mat2cell(A, [1 1], [4 4]);
B11 = B{1,1} % Check Output
B22 = B{2,2} % Check Output

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by