2015-10-13 190 views
0
sampleInput = 

    2.1053 -4.8512 4.6223 0.9665 1.0000 


hiddenWeights = 

    -0.6342 -0.2089 0.4533 -0.6182 -0.3663 
    -0.9465 -1.0770 -0.2668 0.7077 -1.1656 
    0.0936 -0.2853 -0.1408 0.6193 -0.5481 
    1.4253 0.3770 -0.6710 0.1069 0.0310 

我希望结果是隐藏的权重,每列等于上一列* 2.1053。所以hiddenWeights的第一列是:将矩阵中的每列乘以向量中的列乘以

2.1053 * -0.6342 
2.1053 * -0.9464 
etc. 
+0

所以做了什么,我建议帮助? – rayryeng

+0

嗨,我们的答案也有帮助吗? [如何接受一个答案的工作?](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) – rayryeng

回答

7

听起来像是bsxfun工作:

out = bsxfun(@times, hiddenWeights, sampleInput); 

这里,sampleInput会多次出现在hiddenWeights行复制其行,将发生用hiddenWeights与该新矩阵进行元素乘法运算。结果将是hiddenWeights的每一列将与sampleInput中的相应列相乘,并且将成为您的愿望。

+1

我要问OP他们的意思,但这种解释它;) –

1

另一种可能是把sampleInput成一个对角矩阵,并应用矩阵乘法:

result = hiddenWeights*diag(sampleInput); 
+0

这也行! – rayryeng