Tuesday, 6 August 2013

Is bsxfun really element-by-element?

Is bsxfun really element-by-element?

function x = printAndKeepX( x, y )
x
y
end
bsxfun(@printAndKeepX, 1:4, 1);
x =
1 2 3 4
y =
1
If bsxfun was really element-by-element, I would expect printAndKeepX to
be called 4 times, with (x,y)=(1,1);(2,1);(3,1);(4,1). But it's called
just once with (x,y)=([1 2 3 4],1).
Why? How can I know what's considered an "element"?

No comments:

Post a Comment