将大矩阵拆分为较小的矩阵 [英] Split large matrix to smaller ones
本文介绍了将大矩阵拆分为较小的矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个15276x30991
矩阵,我想将其拆分为3
个较小的矩阵,我知道我必须使用mat2cell
函数,但是我无法正确设置尺寸.你能帮我实现这个目标吗?
I have a 15276x30991
matrix and I would like to split it to 3
smaller matrices i know that I have to use mat2cell
function but I cannot manage to set the dimensions correctly. Could you please help me on how can i achieve this?
示例对于要分解为30x25
维的矩阵300x25
的矩阵300x25
,应为
Example For a matrix 300x25
to split in to 10
matrices of 30x25
dimensions should be
Mcell = mat2cell(A,repmat(30,10,1),25)
推荐答案
要将行中的矩阵分成三个矩阵,请尝试:
To split the matrix along the rows into three matrices, try:
>> x = rand(15276,100);
>> C = mat2cell(x, ones(3,1)*(size(x,1)/3), size(x,2))
C =
[5092x100 double]
[5092x100 double]
[5092x100 double]
这假设size(x,1)
被3整除,在您的情况下,这是正确的:15276/3 = 5092
This assumes that size(x,1)
is evenly divisible by 3, which is true in your case: 15276/3 = 5092
这篇关于将大矩阵拆分为较小的矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文