Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Problem 1224. Flexible Anonymous Function

Created by Khaled Hamed

Given a function handle, return a handle to a function that would accept an arbitrary number of inputs, applies the function to each input, and returns an arbitrary number of (respective) outputs (<= the number of inputs, of course).

Example:

 myf=@(x) det(x);
 yourf = flexf(myf);
 [a,~,b,c] = yourf([1 2;3 4],7,[1 2 3; 4 5 6; 2 3 1],3,[2 -1 ; 1 -1])
 a = -2
 b = 9
 c = 3 

Problem Group

Solution Statistics

19 correct solutions 11 incorrect solutions
Last solution submitted on Jul 16, 2014

Solution Comments