MATLAB: Using a function as an input to another

functionsMATLAB

I have a function with two output arguments. I'm trying to pass it as an input to another function where I will need both outputs of the first function.
This is just a minimal example. The two functions:
function [X y] = M(d)
X = d;
[~,Y] = d;
end
function [A B] = N(a)
A = 2*a;
B = 3*a;
end
Basically, I want the following two lines to produce the same output
[a b] =N(3)
M(N(3))

Best Answer

No, when a function has multiple outputs, the only way to capture them all is to use a real function and assign the results to variables. It is not possible in MATLAB to capture multiple outputs of a function inside an expression.