问题描述
我有一个MxN大小的矩阵,比方说1867x3、1867行和3列,我想把它变成1867个大小为1x3的单元格.我使用了mat2cell(X,[1 1866]),这里X是矩阵(1867x3),结果给出了两个像元,一个像元的大小为1x3,另一个像元为1866x3.我希望所有单元格的大小(1867)为1x3.我不知道mat2cell是否可以给我想要的结果,还是应该进行循环以使其发生?谢谢
I have a matrix with the size of MxN, let's say 1867x3, 1867 rows and 3 columns.I I want to make it into 1867 cells with the size of 1x3.I used mat2cell(X,[1 1866]), here X is the matrix (1867x3), the result gave two cells, one cell is the size of 1x3, the other is 1866x3. I want all the cells'(1867) size is 1x3.I don't know if mat2cell could give me the result I want or if I should make a loop so it could happen?Thank you,
推荐答案
尝试一下:
C=mat2cell(X,ones(1,1867),[3]);
该命令基本上说要创建1867个大小为1(行)的单元格,每个单元格包含3个元素.
This command basically says to create 1867 cells of size 1 (in rows) with 3 elements each.
这篇关于使用mat2cell将MxN矩阵划分为1xN大小的M矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!