Description Usage Arguments Value Author(s) Source References Examples
BSXFUN applies a function to each element of 2 arrays with singleton expansion enabled, clone of MATLAB's BSXFUN
1 | BSXFUN(op, x, y)
|
op |
binary function to apply to arrays x and y |
x |
array of numeric or boolean values |
y |
array of numeric or boolean values |
array of numeric or boolean values with the result of function op applied to x and y
Jose Gama
Douglas M. Schwarz, 2006 Generalized Array Operations http://www.mathworks.com/matlabcentral/fileexchange/10333-generalized-array-operations/content/genop.m
Douglas M. Schwarz, 2006 Generalized Array Operations http://www.mathworks.com/matlabcentral/fileexchange/10333-generalized-array-operations/content/genop.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #example 1
x<-matrix(c(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),
5,5,byrow=TRUE)
y<-matrix(13,1,5)
op<-'+'
BSXFUN(op,x,y)
#example 2
d1<-c(4,3,1,2)
x = array(runif(prod(d1)),d1)
d2<-c(4,1,5,2)
y = array(runif(prod(d2)),d2)
op<-'*'
BSXFUN(op,x,y)
#example 3
d1<-c(1,2,5,6,3)
x<-array(1:prod(d1),d1)
d2<-c(1,2,5,1,3,4)
y<-array(1:prod(d2),d2)
op<-'+'
BSXFUN(op,x,y)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.