Cody

Problem 582. Function composition - harder

Solution 1240471

Submitted on 27 Jul 2017 by Augusto Mazzei
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
f1 = @(x)x+1; f2 = @(x)3*x; f3 = @sqrt; h = composeFcn(f1,f2,f3); assert(isequal(h(9),10));

f = function_handle with value: @sqrt h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)3*x h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x))

2   Pass
f = repmat({@(x)x+1},1,100); h = composeFcn(f{:}); assert(isequal(h(0),100));

f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_handle with value: @(x)x+1 h = function_handle with value: @(x)f(h(x)) f = function_...

3   Pass
f = @(x)x; h = composeFcn(f); assert(isequal(h(1234),1234));

f = function_handle with value: @(x)x h = function_handle with value: @(x)f(h(x))

Suggested Problems

More from this Author2

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!