I know I've said it before, but it's still missing and still important:
We need a way to gather all of the outputs of function call into a cell in the middle of an expression .
I know this may be tricky to implement internally. There are internal rules that are hard to work out, that have to do with how many outputs to request from functions. For example,
[A, B] = cellfun(@C, D, 'uniform', 0)
somehow passes knowledge of "two outputs" to C -- for example if you were to use @max then A would be a cell array of the maxima and B would be a cell array of the indices. The situation can get more complicated than this, and figuring out all the cases can make your head hurt. But we do know that any expression C(D(E)) that D(E) will be evaluated asking for exactly one output and that would be passed into C... but the knowledge of multiple outputs would be passed to C and yet not D.
The number of outputs to use is not inherently clear. If for example you call ode45 and ask to gather the outputs, are you asking for the common TOUT, YOUT case, or the full TOUT,YOUT,TE,YE,IE ? There are some cases where extra outputs can be expensive to calculate, so even though an operation that gathered "maximum" outputs might be useful, it is not always desireable, so ability to select the number would be useful.
Then there are issues with, for example, deal(), where you can have any number of outputs with just a single input:
would initialize A, B, C, and D all to 123. So if you ask to gather "all" of the outputs from deal(123), that number is not well defined.
Working these things out is not trivial -- but it is a really missing bit of the language.
There might be an opportunity for a syntax such as {}name -- e.g.,
arrayfun(@(X0) {}ode45(@f, tspan, X0), x0s)
meaning to gather all of the outputs of the call. At present, {} is not valid before a name.
2 Comments
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/573463-what-is-missing-from-matlab-2-the-next-decade-edition#comment_956557
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/573463-what-is-missing-from-matlab-2-the-next-decade-edition#comment_956557
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/573463-what-is-missing-from-matlab-2-the-next-decade-edition#comment_956698
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/573463-what-is-missing-from-matlab-2-the-next-decade-edition#comment_956698
Sign in to comment.