Skip to content

treefun* functions support variable output arguments #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ejrx
Copy link

@ejrx ejrx commented Sep 23, 2016

Hi,

While using your library, I came across the need to have treefun return multiple values for a given tree (similar to how cellfun or arrayfun work).

An example of how it works:

function [a,s] = add_sub_one(val)
    a = val+1; s = val + 1;
end
>> disp(t.tostring)
 1 
++-+
|  |
2  3
>> [ta,ts] = t.treefun(@add_sub_one);
>> disp([ta.tostring ts.tostring])
 2     0
++-+  ++-+
|  |  |  |
3  4  1  2

Note that this does not break the API for these functions, so single-return-value functions can be called the same as they have been.

I've tested on R2014b and R2015b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant