Cody

Solution 1238703

Submitted on 25 Jul 2017 by Anupam Agarwal
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   Pass
y11 = [4 3 0 3]; y21 = [2 0 1 3]; x11 = [0 1 1 2]; x21 = [-2 4 1 2]; a1 = [-2 4 0 2]; assert(isequal(piecewise(x11, y11, x21, y21),a1))

2   Pass
y12 = [2 2 2 2]; y22 = [0 4 0 4]; x12 = [1 1 1 1]; x22 = [1 1 1 1]; a2 = [1 0 1 0]; assert(isequal(piecewise(x12, y12, x22, y22),a2))

3   Pass
y23 = [2 2 2 2]; y13 = [0 4 0 4]; x13 = [2 2 2 2]; x23 = [2 2 2 2]; a3 = [0 2 0 2]; assert(isequal(piecewise(x13, y13, x23, y23),a3))

4   Pass
y14 = zeros(1, 100); y24 = ones(1, 100); x14 = ones(1,100); x24 = 2*ones(1,100); a4 = zeros(1, 100); assert(isequal(piecewise(x14, y14, x24, y24),a4))

5   Pass
y25 = 2; y15 = 0; x15 = 2; x25 = 2; a5 = 0; assert(isequal(piecewise(x15, y15, x25, y25),a5))