0

我有一个矩阵mymat和一个向量v。如何将向量乘以v矩阵的每一列mymat并得到以下结果?

    mymat = matrix(c(6, 4, 6, 2, 5, 8), nrow=3, ncol=2)
    mymat
    v  =c(2, 4, 6)
    > result
        [,1] [,2]
   [1,]   12    4
   [2,]   16   20
   [3,]   36   48
4

1 回答 1

1
    > mymat * v
     [,1] [,2]
[1,]   12    4
[2,]   16   20
[3,]   36   48

就那么简单

于 2013-07-20T08:57:39.877 回答