Path: news.mathworks.com!newsfeed-00.mathworks.com!newscon02.news.prodigy.net!prodigy.net!news.glorb.com!hwmnpeer01.lga!hwmnpeer03.lga!news.highwinds-media.com!llnews!53ab2750!not-for-mail
Newsgroups: comp.soft-sys.matlab
Subject: Re: Suggesting improvements to Matlab
References: <f8vib1$sb7$1@fred.mathworks.com>
From: Peter Boettcher <boettcher@ll.mit.edu>
Message-ID: <muyir7wzkfa.fsf@G99-Boettcher.llan.ll.mit.edu>
Organization: MIT Lincoln Laboratory
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.98 (gnu/linux)
Cancel-Lock: sha1:xa04otpxMTxkXkKC3xyYDhs2p30=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Lines: 42
Date: Fri, 03 Aug 2007 11:50:49 -0400
NNTP-Posting-Host: 155.34.163.114
X-Complaints-To: news@ll.mit.edu
X-Trace: llnews 1186155983 155.34.163.114 (Fri, 03 Aug 2007 11:46:23 EDT)
NNTP-Posting-Date: Fri, 03 Aug 2007 11:46:23 EDT
Xref: news.mathworks.com comp.soft-sys.matlab:422367


"Oliver Woodford" <o.j.woodford.98@cantab.net> writes:

> Hi all
>
> I'm sure we all have improvements we'd like to make to
> Matlab - my colleagues and I are forever discussing them. I,
> for one, have no idea how to go about suggesting them to
> MathWorks, but doubt they would be implemented if I did
> anyway. Instead I thought I'd send them here for feedback
> and to gauge support. Others might add their own suggestions
> also. One of the MathWorks team might see them too.
>
> Firstly it's important to note that improvements should not
> break any old code - I don't believe these do, as long as
> the code doesn't rely on any errors occurring (which may no
> longer occur due to extended functionality).
>
> Improvements to array operators (+, -, .*, ./):
> Currently you can use these on two matrices of the same
> size, or a matrix and a scalar.
> I would like them to also be valid for a larger set of pairs
> of matrices, which would include any pair of matrices A and
> B where each dimension of A is either the same as the
> respective dimension of the B, or 1.
> This would allow you to combine (using the above operators)
> A and B, where (for example):
> size(A) = [1 3 4 1 1];
> size(B) = [10 3 4 7 2];
> Currently you would do:
> B + repmat(A, [10 1 1 7 2]);
> or use nested for loops.
> The benefit of having this functionality built in is that
> you don't need to waste time and memory replicating data (or
>  doing for loops). It would be especially useful when B is
> huge and A is small.

The new function bsxfun in MATLAB 7.3 does this.  For your example:

bsxfun(@plus, A, B)


-Peter