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 195937

Submitted on 24 Jan 2013 by Alfonso Nieto-Castanon

Correct

23Size
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
Pass
 
%%
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));

                    
2
Pass
 
%%
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])));