On Tue, Jun 23, 2009 at 8:02 PM, Judd Storrs
<address@hidden> wrote:
On Tue, Jun 23, 2009 at 7:40 PM, Judd Storrs
<address@hidden> wrote:
On Tue, Jun 23, 2009 at 6:39 PM, ws
<address@hidden> wrote:
I would love to now get the row frequencies avoiding a while loop, something
like F=X./S, but that doesn't work (though it seems somehow consistent -- I
realize that we don't recycle vectors in Octave/ Mat* ) ....
Are trying to divide each row by its sum? I think the bsxfun will do this:
bsxfun(@times,X,1./S)
I'm not sure if there is a direct function name for "./". If you can figure that out you can also avoid the separate division.
--judd
I found it. It's @ldivide
tic
Y1 = X ./ repmat(sum(X,2),[1 columns(X)]);
toc
Elapsed time is 0.02987 seconds.
tic
Y2 = bsxfun(@times,X,1./sum(X,2));
toc
Elapsed time is 0.0077 seconds.
tic
Y3 = bsxfun(@rdivide,X,sum(X,2));
toc
Elapsed time is 0.0002439 seconds.
--judd