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 84923

Submitted on 2 May 2012 by Bart Vandewoestyne

Correct

77Size
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
 
%%
x = (1:20)';
fh = @(xi) mod(xi, 2) == 0;
y_correct = (2:2:20)';
assert(isequal(filterfun(fh, x), y_correct));

                    
2
Pass
 
%%
x = 'Aa is lava.';
fh = @(c) lower(c) == 'a';
y_correct = 'Aaaa';
assert(isequal(filterfun(fh, x), y_correct));

                    
3
Pass
 
%%
x = {[]; 1; [1;2]; [2 3 4]; ones(1,1,3)};
fh = @isrow;
y_correct = {1; [2 3 4]};
assert(isequal(filterfun(fh, x), y_correct));