Your first matrix has five rows and two columns; your second matrix has five rows and one column. If they have the same number of rows, and the second always has one column, you can do
mat1 * rep(mat2,ncol(mat1)) [,1] [,2] [1,] -0.2327958 0.76093047 [2,] -0.3636661 -0.18991299 [3,] -0.8729468 0.58214118 [4,] 0.8017349 -0.59781909 [5,] -0.2230380 -0.08296606
If mat1 actually had as many elements in its rows as mat2 had in its only column (as your words suggest), you would slightly adjust this
mat1 <- matrix(rnorm(10), nrow=2, ncol=5) mat2 <- matrix(rnorm(5), nrow=5, ncol=1) mat1 * rep(mat2,nrow(mat1)) [,1] [,2] [,3] [,4] [,5] [1,] -0.19818805 -0.05938007 -1.7792597 0.06937307 -0.7193403 [2,] -0.05087793 0.10781853 0.2243285 -0.11416273 2.4063926
or in sarah version
mat1 <- matrix(rnorm(10), nrow=5, ncol=2) mat2 <- matrix(rnorm(2), nrow=2, ncol=1) mat1 * rep(mat2,nrow(mat1)) [,1] [,2] [1,] 0.1528393 0.68646359 [2,] 0.2420454 0.22987250 [3,] -0.2592124 -0.07626098 [4,] 0.4431273 0.27320838 [5,] -0.1698307 0.47578667