I’m wondering if anyone has coded bsxfun and wishes to share it :)

Basically bsxfun is matlab’s way of performing the same action to multiple data sets - a generalization of diagonal matrix operations. For example:

Adding/subtracting/multiplying/dividing/maximum/minimum of an m*1 vector with each column of an m*n matrix

Adding/subtracting/multiplying/dividing/maximum/minimum of an 1*n row vector with each row of an m*n matrix

There are further functions that can be applied between two elements obviously - power, modulus,logical operations spring to mind - but that’s the easy part. This is one of the basic building blocks of linear algebra, and is particularly useful for sparse linear algebra (whereby diagonal matrices are stored as vectors - taking the inverse then is simply V./D for some vector-to-solve V)