Cody

# Problem 260. Create a function handle that reverses the input arguments of another function handle

Solution 2105422

Submitted on 25 Jan 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 = @(x,y) 2*x+y; g = reverseArguments(f); assert(isequal(g(5,6), 17)); assert(isequal(g(6,5), 16));

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In reverseArguments (line 2) In ScoringEngineTestPoint1 (line 2) In solutionTest (line 3)]

Index in position 1 exceeds array bounds (must not exceed 1). Error in Test1 (line 3) assert(isequal(g(5,6), 17));

2   Fail
f = @(x,y) x.^y; g = reverseArguments(f); assert(isequal(g(2,3), 9));

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In reverseArguments (line 2) In ScoringEngineTestPoint2 (line 2) In solutionTest (line 5)]

Index in position 1 exceeds array bounds (must not exceed 1). Error in Test2 (line 3) assert(isequal(g(2,3), 9));

3   Fail
f = @(A,theta) A*sin(theta); g = reverseArguments(f); assert(isequal(g(4,10), 10*sin(4)));

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In reverseArguments (line 2) In ScoringEngineTestPoint3 (line 2) In solutionTest (line 7)]

Index in position 1 exceeds array bounds (must not exceed 1). Error in Test3 (line 3) assert(isequal(g(4,10), 10*sin(4)));

### Community Treasure Hunt

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

Start Hunting!