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 189761

Submitted on 11 Jan 2013 by Alfonso Nieto-Castanon

Correct

29Size
Leading solution size is 24.
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
 
%%
f{1}=@(x) x^2;
f{2}=@(x) x+3;
f{3}=@(x) x/2;
g=cf(f);
x=[1 2 3];
y_correct = [2 3.5 6];
assert(isequal(g(x),y_correct))

                    
2
Pass
 
%%
f{1}=@(x) x^0.5;
f{2}=@(x) x-1;
f{3}=@(x) x^2;
f{4}=@(x) x/3;
g=cf(f);
x=[ 16 49 100];
y_correct = [3 12 27];
assert(isequal(g(x),y_correct))