2017-06-02 243 views
-1

我有一个存储为x(:,:1)和x(:,:2)的矩阵(100x50,它有随机数)。我想计算与这些矩阵的行和列对应的平均值,但目前为止没有运气。我试图使用平均函数,但它只给我一个值。算法的任何提示?计算三维矩阵之间的平均值

回答

1

你可以像下面的每个矩阵:

mean(x(:,:,1),1) //avg in columns of x(:,:,1) 
    mean(x(:,:,1),2) //avg in row of x(:,:,1) 

您也可以使用下面的代码获得不同尺寸X的意思是:

mean(x,3); // size 100x50, avg of element of the two matrices 
mean(x,2); // size 100 x 1 x 2, avg of rows of the two matrices 
mean(x,1); // size 1 x 50 x 2, avg of columns of the two matrices 
+0

你看你怎么写“是什么意思(x(:,:1),1)// avg在x(:,:,1)'的列中,你是指列还是列? –