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

Solution 195857

Submitted on 24 Jan 2013

Incorrect

25Size
Leading solution size is 22.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Fail
 
%%
myf=@(x) det(x);
yourf = flexf(myf);
x={[1 2;3 4],7,[1 2 3; 4 5 6; 2 3 1],3,[2 -1 ; 1 -1]};
[a,~,b,c]=yourf(x{:});
y_correct = {-2 9 3};
assert(isequal({a b c},y_correct));
Error: The number of outputs should match the number of inputs.
2
Fail
 
%%
myf=@(x) x.^2;
yourf = flexf(myf);
x={[1 2;3 4],7,[1 2 3; 4 5 6; 2 3 1],3,[2 -1 ; 1 -1]};
[a,~,b,c]=yourf(x{:});
y_correct = cellfun(myf,x,'uni',0);
assert(isequal({a b c},y_correct([1 3 4])));
Error: The number of outputs should match the number of inputs.