Cody

# Problem 2641. Dispatch and collect

Solution 2169770

Submitted on 22 Mar 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
x = [1 2 6; 2 7 5; 3 5 4]; co1 = [1 2 4; 3 7 6]; co2 = [1 1 3; 3 2 1]; [o1, o2] = dispatch(x, @min, @max); assert(isequal(o1, co1) && isequal(o2, co2))

ans = 2 varargout = 1×1 cell array {2×3 double}

Output argument "varargout{2}" (and maybe others) not assigned during call to "dispatch". Error in Test1 (line 4) [o1, o2] = dispatch(x, @min, @max);

2   Pass
x = randi(50, 20); co = [mean(x); mode(x); median(x)]; assert(isequal(co, dispatch(x, @mean, @mode, @median)))

ans = 1 varargout = 1×1 cell array {3×20 double}

3   Pass
x=10; co = [zeros(x);ones(x);eye(x);magic(x);pascal(x)]; assert(isequal(co, dispatch(x, @zeros, @ones, @eye, @magic, @pascal)))

ans = 1 varargout = 1×1 cell array {50×10 double}

4   Fail
co = randi(50, 1, 4); [o1, o2, o3, o4] = dispatch(zeros(co), @size); assert(isequal([o1 o2 o3 o4], co))

ans = 4 varargout = 1×1 cell array {1×4 double}

Output argument "varargout{2}" (and maybe others) not assigned during call to "dispatch". Error in Test4 (line 2) [o1, o2, o3, o4] = dispatch(zeros(co), @size);

### Community Treasure Hunt

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

Start Hunting!