Learn R Programming

pracma (version 1.2.5)

bsxfun: Elementwise Function Application (Matlab Style)

Description

Apply a binary function elementwise.

Usage

bsxfun(f, x, y, ...)

Arguments

f
function with two input parameters.
x, y
two vectors, matrices, or arrays of the same size.
...
optional parameters to be passed to the function.

Value

  • The result will be a vector or matrix of the same size as x, y.

Details

Apply element-by-element a binary function to two vectors or matrices of the same size.

See Also

Vectorize

Examples

Run this code
X <- matrix(rep(1:10, each = 10), 10, 10)
Y <- t(X)
bsxfun("*", X, Y)  # multiplication table

Run the code above in your browser using DataLab