[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bsxfun for arrays
From: |
Jordi Gutiérrez Hermoso |
Subject: |
Re: bsxfun for arrays |
Date: |
Fri, 13 May 2011 23:27:07 -0500 |
2011/5/13 Jordi Gutiérrez Hermoso <address@hidden>:
> While working on #33292, I came across a behaviour of bsxfun I don't
> understand:
>
> x = rand(1,1,3); y= rand(2,2,3); u = bsxfun(@(t) t, x,y); sum(u(2,:))
>
> That above outputs zero at changeset b6eaecf83bb2 because all of
> u(2,:) is zero. I don't get it. Why wasn't the "vertical vector" x
> copied four times?
To expand on this, the following does output what I would expect:
x = rand(1,1,3); y= rand(2,2,3); u = bsxfun(@(t,s) t+s-s, x,y);
sum(u(2,:))
but removing that +s-s, I get a different output.
- Jordi G. H.
>
> I had someone try this in Matlab, and they reported that it errored
> out with "Error using ==> bsxfun: Invalid output dimensions" which I
> find even more mystifying. Who specified anything about output
> dimensions?
>
> TIA,
> - Jordi G. H.
>
- bsxfun for arrays, Jordi Gutiérrez Hermoso, 2011/05/13
- Re: bsxfun for arrays,
Jordi Gutiérrez Hermoso <=