Transfer from http://www.cnblogs.com/rong86/p/3559616.html
function function: Two elements of an array of two-value operations calculated on a single basis
How to use: C=bsxfun (fun,a,b)
Two arrays A-in-B elements are computed two-value operations, fun is a function handle or m file, or it can be a built-in function as follows:
@plus Plus
@minus minus
@times arrays by "Simulink and Signal Processing"
@rdivide left except
@ldivide right except
@power Array Power multiplication
@max two-valued maximum value
@min minimum value of two values
@rem remainder
@mod to find a mold
@atan2 Four quadrant Arc tangent
Square root of @hypot squared sum
@eq equals
@ne Not equal to
@lt less than www.iLoveMatlab.cn
@le less than or equal to
@gt Greater than
@ge greater than or equal to
@and Logic and
@or Logical OR
@xor Logical XOR or
Application Examples:
In this example, the Bsxfun function is used to calculate the average of each column in matrix A minus its corresponding column.
A = Magic (5)
A =
17 24 1) 8 15
23 5 7) 14 16
4 6 13) 20 22
10 12 19) 21 3
11 18 25) 2 9
A = Bsxfun (@minus, A, mean (a)) book.iLoveMatlab.cn
A =
4 11-12-5 2
10-8-6 1 3
-9-7 0 7 9
-3-1 6 8-10
-2 5 12-11-4
function Bsxfun, two-value operation calculated on a per-array basis between two elements