Cody

Problem 42502. Combine Data With Gaps

Solution 3349158

Submitted on 23 Oct 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   Pass
a = [1,0; 2,1; 3,5; 5,2; 6,3]; b = [1,2; 3,6; 4,3; 6,4] d_correct = [1,0,2; 2,1,0; 3,5,6; 4,0,3; 5,2,0; 6,3,4]; assert(isequal(comb_gap(a,b),d_correct))

b = 1 2 3 6 4 3 6 4

2   Fail
a = []; b = []; d_correct = []; assert(isequal(comb_gap(a,b),d_correct))

Index in position 2 exceeds array bounds. Error in comb_gap (line 3) u = unique(ab(:,1)); Error in Test2 (line 4) assert(isequal(comb_gap(a,b),d_correct))

3   Fail
a = []; b = [1,2; 4,8; 7,2]; d_correct = [1,2; 4,8; 7,2]; assert(isequal(comb_gap(a,b),d_correct))

Index in position 2 exceeds array bounds. Error in comb_gap (line 7) ix = find(a(:,1)==u(i)); Error in Test3 (line 8) assert(isequal(comb_gap(a,b),d_correct))

4   Pass
a = [0.5183,0.2425; 0.7750,0.3880; 0.9400,0.3395; 1.5800,0.5335; 2.5467,0.2425]; b = [0.5183,0.2568; 0.9400,0.3492; 1.1383,0.3395; 2.1200,0.3395; 2.5467,0.2315]; d_correct = [0.5183,0.2425,0.2568; 0.7750,0.3880,0 ; 0.9400,0.3395,0.3492; 1.1383,0 ,0.3395; 1.5800,0.5335,0 ; 2.1200,0 ,0.3395; 2.5467,0.2425,0.2315]; assert(isequal(comb_gap(a,b),d_correct))

5   Pass
a = [0 ,0 ; 0.5183,0.2425; 0.7750,0.3880; 0.9400,0.3395; 1.5800,0.5335; 2.5467,0.2425]; b = [0 , 0 ; 0.7117,-0.6794; 0.8650,-0.4854; 1.2550,-0.5824; 1.3317,-0.6309; 1.4467,-0.5824; 1.7050,-0.6309; 1.7717,-0.6794]; d_correct = [0 ,0 , 0 ; 0.5183,0.2425, 0 ; 0.7117,0 ,-0.6794; 0.7750,0.3880, 0 ; 0.8650,0 ,-0.4854; 0.9400,0.3395, 0 ; 1.2550,0 ,-0.5824; 1.3317,0 ,-0.6309; 1.4467,0 ,-0.5824; 1.5800,0.5335, 0 ; 1.7050,0 ,-0.6309; 1.7717,0 ,-0.6794; 2.5467,0.2425, 0 ]; assert(isequal(comb_gap(a,b),d_correct))

Suggested Problems

More from this Author1

Community Treasure Hunt

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

Start Hunting!