Cody

Solution 1739639

Submitted on 1 Mar 2019 by Martin C.
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))

y = [] y = -2 y = -2 4 y = -2 4 0 y = -2 4 0 2

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

y = [] y = 1 y = 1 0 y = 1 0 1 y = 1 0 1 0

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

y = [] y = 0 y = 0 2 y = 0 2 0 y = 0 2 0 2

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

y = [] y = 0 y = 0 0 y = 0 0 0 y = 0 0 0 0 y = 0 0 0 0 0 y = 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 30 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 31 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 32 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 33 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 34 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 35 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 36 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 37 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 38 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 39 0 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 40 0 0 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 41 0 0 0 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 42 0 0 0 0 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 43 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 46 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 49 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 51 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 52 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

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

y = [] y = 0