Have matrix A that have size x by y and matrix B with x by 1
矩阵A的大小为x乘y,矩阵B的x乘以x
in matrix B have an element that represent kind of co factor that correspondent with matrix A I want the program A * B ( A * factor of each array )
在矩阵B中有一个元素代表与矩阵A对应的辅因子类型我希望程序A * B(每个数组的A *因子)
Example
例
A (4 * 3) = [ 2 4 6 ;
5 10 15 ;
7 11 13 ;
1 1 1];
B (4 * 1) = [ 4 ; 1/5 ; 3 ; 7];
I want A * B like [ 2*4 , 4*4 , 6*4
;5/5 , 10/5 , 15/5
;7*3 , 11*3 , 13*3
;1*7 , 1*7 , 1*7];
expected RESULT = [ 8 16 24 ; 1 2 3 ; 21 33 39 ; 7 7 7];
I try to use scalar multiplication but it didn't work since scalar multiplication must have same size of array how do I to solve this?
我尝试使用标量乘法,但由于标量乘法必须具有相同的数组大小,我怎么解决这个问题呢?
1 个解决方案
#1
1
Use bsxfun
to get your desired result of multiplying the row elements of A
with the single row value in B
使用bsxfun获得所需的结果,即将A的行元素与B中的单行值相乘
bsxfun(@times,A,B)
#1
1
Use bsxfun
to get your desired result of multiplying the row elements of A
with the single row value in B
使用bsxfun获得所需的结果,即将A的行元素与B中的单行值相乘
bsxfun(@times,A,B)