Handle to an array of functions - MATLAB Cody - MATLAB Central

Problem 1198. Handle to an array of functions

Difficulty:Rate

Given a cell array of functions that operate on scalars, it is required to return a function handle to process a vector of values applying the functions successively (the first function operates on x, the second function operates on the resulting output, etc.).

Example:

 >> f{1}=@(x) x^2;
 >> f{2}=@(x) x+3;
 >> f{3}=@(x) x/2;
 >> g=cf(f);
 >> x=[1 2 3];
 >> g(x)
 ans =
     2.0000    3.5000    6.0000

Solution Stats

30.15% Correct | 69.85% Incorrect
Last Solution submitted on Jun 02, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
3
4

Problem Recent Solvers58

Suggested Problems

More from this Author11

Community Treasure Hunt

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

Start Hunting!