Write a function that accepts an arbitrary number of function handles f_1, f_2, ..., f_n and returns the composition h. That is,
h = (f_1 o f_2 o ... o f_n)(x) = f_1(f_2( ... f_n(x) ... ))
Example:
>> f1 = @(x)x+1; >> f2 = @(x)3*x; >> f3 = @sqrt; >> h = composeFcn(f1,f2,f3); >> h(9) ans = 10
because 3*sqrt(9)+1 = 10.
You can assume that there will always be at least one input passed to the composeFcn function.
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers106
Suggested Problems
-
1358 Solvers
-
500 Solvers
-
Project Euler: Problem 6, Natural numbers, squares and sums.
2535 Solvers
-
Find Index of maximum Value and maximum Value of a vector
167 Solvers
-
Calculate the height of an object dropped from the sky
283 Solvers
More from this Author2
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
"compose" is a built-in Matlab function.
Please, change the function name in the test suite, since no new solution is allowed.
Composition is in reverse. Apply last function, then next-to-last, and so forth to first.