Cody

Problem 1198. Handle to an array of functions

Solution 3586635

Submitted on 8 Nov 2020
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   Fail
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))

Undefined function 'plus' for input arguments of type 'function_handle'. Error in cf (line 5) y = y + @(z) x(z(i)); Error in Test1 (line 4) g=cf(f);

2   Fail
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))

Undefined function 'plus' for input arguments of type 'function_handle'. Error in cf (line 5) y = y + @(z) x(z(i)); Error in Test2 (line 5) g=cf(f);

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!