Main Content

dmbsxfun

Apply element-by-element binary operation to two DataMatrix objects with singleton expansion enabled

Syntax

DMObjNew = dmbsxfun(Func, DMObj1, DMObj2)

Input Arguments

Func

Function handle for a function or a built-in function. For more information on built-in functions, see bsxfun.

DMObj1, DMObj2

Either of the following:

  • DataMatrix object, such as created by DataMatrix (object constructor)

  • MATLAB® numeric array

At least one of these input arguments must be a DataMatrix object.

Output Arguments

DMObjNewDataMatrix object or MATLAB numeric array created from element-by-element binary operation of two DataMatrix objects with singleton expansion enabled.

Description

DMObjNew = dmbsxfun(Func, DMObj1, DMObj2) applies an element-by-element binary operation to the DataMatrix objects DMObj1 and DMObj2, with singleton expansion enabled. Func is a function handle, and can be for a function or a built-in function. For more information on built-in functions, see bsxfun.

DMObj1 and DMObj2 can be DataMatrix objects or MATLAB numeric arrays; however, at least one of these input arguments must be a DataMatrix object. DMObj1 and DMObj2 must have the same number of rows or the same number or columns. If they don't have the same number of rows, then one must be a row vector and its rows are expanded down to be equal to the larger matrix. If they don't have the same number of columns, then one must be a column vector and its columns are expanded across to be equal to the larger matrix.

DMObjNew is a DataMatrix object, unless the larger input argument is a MATLAB numeric array; then DMObjNew is also a numeric array. The size (number of rows and columns) of DMObjNew is equal to the larger of the two input arguments. The row names and column names of DMObjNew come from the larger input argument, or, if both inputs are the same size, from the first input argument.

Examples

  1. Use the DataMatrix constructor function to create a DataMatrix object.

    A = bioma.data.DataMatrix(magic(3), 'RowNames', true, ...
                              'ColNames',true)
  2. Use the built-in function @minus to subtract the column means from this DataMatrix object.

    A = dmbsxfun(@minus, A, mean(A))

Version History

Introduced in R2008b

See Also

|