Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: I'm dense, but...somebody 'splain accumarray() please?
Replies: 23   Last Post: Jul 11, 2013 1:00 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Kelly Kearney

Posts: 24
Registered: 4/25/13
Re: I'm dense, but...somebody 'splain accumarray() please?
Posted: Jul 11, 2013 11:03 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

dpb <none@non.net> wrote in message <krkn62$b02$1@speranza.aioe.org>...

> Does it eliminate the intermediary storage or only move it to a level
> below the calling function so it does (at least which is _a_good_thing_
> (tm) ) vanish silently?


Yeah, it justs moves the index step into function, so you don't need to worry about it. Regarding getting certain outputs only, perhaps a wrapper function like:

%---
function varargout = outnum(fun, idx, varargin)
% fun: handle to function
% idx: output #s you want to keep
% varargin: input variables to the function
varargout = cell(1, max(idx));
[varargout{:}] = fun(varargin{:});
varargout = varargout(idx);
%---

(I haven't tested that thoroughly, but I think it should work).

So, for example:

test = round(rand(20,1)*10);
accumarray(outnum(@unique,3,test), test, [10 1], @(x) {x})

Again, it only moves the collection and disposal of extra output variables to a different workspace, rather than eliminating it altogether, but it would allow for easier one-liners.
Though perhaps pretty difficult-to-read ones (of course, I feel the same way about bsxfun, especially when I have to combine 3 or 4 bsxfun operators in a single equation).


> > And regarding the other topic of this thread, I also hate the new
> > documentation. But I've been lamenting changes on that front ever since
> > they eliminated the Index... it's simply gotten worse and worse since
> > then. The crash-Matlab-completely-for-no-apparent-reason feature of the
> > R2013a Help Browser is a particularly nice touch, though. Ugh.

>
> That's disheartening to hear it hasn't yet gone away--I found it in R2012b.


Ah, well, I skipped straight from 2012a to 2013a, so I'm just discovering it. Unfortunately, I have to upgrade for my site license, or I think I would gladly revert to R2008b, the last version that I felt truly offered me an upgrade.


>
> --



Date Subject Author
7/5/13
Read I'm dense, but...somebody 'splain accumarray() please?
dpb
7/5/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
dpb
7/6/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
james bejon
7/8/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
Steven Lord
7/8/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
dpb
7/9/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
Steven Lord
7/9/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
dpb
7/10/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
Marc
7/10/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
Kim Andrews
7/10/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
dpb
7/10/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
dpb
7/10/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
dpb
7/10/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
EBS
7/10/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
dpb
7/10/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
EBS
7/10/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
dpb
7/10/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
Kelly Kearney
7/10/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
dpb
7/10/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
dpb
7/11/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
Kelly Kearney
7/11/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
dpb
7/10/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
Kelly Kearney
7/10/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
dpb
7/11/13
Read Re: I'm dense, but...somebody 'splain accumarray() please?
Steven Lord

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.