调用格式:
c=bsxfun(fun,A,B)
matlab文档定义:实现阵列元素和元素之间func操作,一定情况下可以某维度实现自动展开。
@plus
@minus
@times
@rdivide
@ldivide
@power
@max
@min
@rem
@mod
@atan2
@atan2d
@hypot
@eq
@ne
@lt
@le
@gt
@ge
@and
@or
@xor
以减法为实验对象:
**相同维度:**
>>A =
-19 0
-2 2
6 3
>>B =
30 -11
-6 9
5 7
>> bsxfun(@minus,A,B)
ans =
-49 11
4 -7
1 -4
拓展维度:
>> MA=mean(A)
MA =
-5.0000 1.6667
>>> bsxfun(@minus,A,MA)
ans =
-14.0000 -1.6667
3.0000 0.3333
11.0000 1.3333
当有一个维度不同时并有个维度为1,则可拓展此维度。