关于bsxfun 函数的详细说明!
帮助文档中是这么说的:C = bsxfun(fun,A,B)
applies the element-by-element binary operation specified by the function handle fun to arrays A and B, with singleton expansion enabled. (两个数组间元素逐个计算,fun是函数句柄或者m文件)
fun可以选择下列函数:@plus//加
@minus//建
@times//乘
@rdivide//
@ldivide//
@power//
@max//
@min//
@rem//
@mod//
...(查看Matlab帮助文档)
C = bsxfun(fun,A,B) //注意是逐个元素操作,也就是A和B对于位置的元素执行fun操作,那么势必size大小一致。如果不一致怎么办呢?
bxsfun会隐式地对A或B执行“隐式的”repmat(不会实际地造成内存开销,repmat函数会奥)。举个例子:
![这里写图片描述](https://img-blog.csdn.net/20161010104349096)
![这里写图片描述](https://img-blog.csdn.net/20161010104712759)
结果一致,如此而已!fun可以也可以是M文件