例如,给定一个矩阵randn(3,2)--3行,2列和乘数randn(1,2))2列的向量,我想得到一个大小的向量,(3, 1)其中每行代表矩阵行元素和给定乘数的每个元素乘法的总和
row_element_1*mul_element_1 + row_element_2*mul_element_2
Run Code Online (Sandbox Code Playgroud)
听起来你想要一个矩阵向量乘法.
1> x = randn(3, 2)
x =
0.62055 -1.08060
-0.24064 -2.56097
-0.53202 -0.49712
2> y = randn(1, 2)
y =
-1.26010 -0.25200
3> x * y'
ans =
-0.50964
0.94860
0.79567
Run Code Online (Sandbox Code Playgroud)
注意换位y'.