%% Return Multiple Outputs from Anonymous Function
% You can create an anonymous function to define a function without creating a program file, as long as the function contains a single executable statement. One way to return multiple output arguments from an anonymous function is to call the deal function as that single executable statement.
% Create an anonymous function that returns a number and its square, cube, and fourth power by using the deal function. To store the anonymous function, assign it to a function handle.

powers1234 = @(x) deal(x,x.^2,x.^3,x.^4)

%
% Call powers1234 and assign its outputs to variables. You must assign all outputs that deal returns.

[X1,X2,X3,X4] = powers1234(2)

%
% To discard unwanted outputs, use the ~ operator.

[~,~,X3,X4] = powers1234(2)

% Copyright 2020 The MathWorks, Inc.