Problem 581. Function composition

Write a function that accepts two function handles f and g and returns the composition h. That is,

h = (f o g)(x) = f(g(x))


>> f = @(x)x^2;
>> g = @(x)x+1;
>> h = composeFcn(f,g);
>> h(3)
ans =

because (3+1)^2 = 16.

Solution Stats

44.85% Correct | 55.15% Incorrect
Last Solution submitted on Apr 17, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers229

Suggested Problems

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!