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 m1 vector with each column of an mn matrix
Adding/subtracting/multiplying/dividing/maximum/minimum of an 1n row vector with each row of an mn 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)