Skip to content

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