I am unable to write MATLAB code without creating a huge number of extra one-time variables.
For example, suppose the function foo returns three column vectors of exactly the same size. Say:
function [a, b, c] = foo(n) a = rand(n, 1); b = rand(n, 1); c = rand(n, 1); end
Now suppose bar is a function that expects an array of cells of size (1, 3) as imput.
function result = bar(triplet) [x, y, z] = triplet{:}; result = x + y + z; end
If I want to pass the results to foo(5) , I can do this by creating three otherwise useless variables:
[x, y, z] = foo(5); result = bar({x, y, z});
Is there some kind of baz function that would allow me to replace the two lines above with
result = bar(baz(foo(5)));
?
NB: the functions foo and bar above are provided as examples only. They should represent functions that I do not control. IOW, changing them is not an option.
source share