Cody

Problem 42671. unique with nan

Solution 3315693

Submitted on 21 Oct 2020 by Nikolaos Nikolaou
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
x = [2 NaN 3 5 NaN; 1 NaN 4 9 NaN; 8 -2 7 6 -2; 7 4 8 5 4];; y_correct = [2 NaN 3 5; 1 NaN 4 9; 8 -2 7 6; 7 4 8 5]; assert(isequalwithequalnans(unique_with_nan(x),y_correct))

y = 7 8 1 2 4 -2 Inf Inf 8 7 4 3 5 6 9 5 4 -2 Inf Inf y = 7 8 1 2 4 -2 Inf Inf 8 7 4 3 5 6 9 5 y = 2 Inf 3 5 1 Inf 4 9 8 -2 7 6 7 4 8 5 y = 2 NaN 3 5 1 NaN 4 9 8 -2 7 6 7 4 8 5

2   Pass
x = [1 0 0 1;NaN 1 0 NaN;NaN 0 1 NaN;0 0 0 0]; y_correct = [1 0 0;NaN 1 0;NaN 0 1;0 0 0]; assert(isequalwithequalnans(unique_with_nan(x),y_correct))

y = 0 Inf Inf 1 0 0 1 0 0 1 0 0 0 Inf Inf 1 y = 0 Inf Inf 1 0 0 1 0 0 1 0 0 y = 1 0 0 Inf 1 0 Inf 0 1 0 0 0 y = 1 0 0 NaN 1 0 NaN 0 1 0 0 0

3   Pass
x = [1 0 1 1 1 1 0;0 1 1 1 1 1 0;0 0 NaN NaN NaN NaN 0;0 0 NaN NaN NaN NaN 0;0 0 NaN NaN NaN NaN 0;0 0 0 0 0 0 0;0 0 0 0 0 0 1]; y_correct = [1 0 1 0;0 1 1 0;0 0 NaN 0;0 0 NaN 0;0 0 NaN 0;0 0 0 0;0 0 0 1]; assert(isequalwithequalnans(unique_with_nan(x),y_correct))

y = 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 Inf Inf Inf 1 1 0 0 Inf Inf Inf 1 1 0 0 Inf Inf Inf 1 1 0 0 Inf Inf Inf 1 1 1 0 0 0 0 0 0 y = 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 Inf Inf Inf 1 1 1 0 0 0 0 0 0 y = 1 0 1 0 0 1 1 0 0 0 Inf 0 0 0 Inf 0 0 0 Inf 0 0 0 0 0 0 0 0 1 y = 1 0 1 0 0 1 1 0 0 0 NaN 0 0 0 NaN 0 0 0 NaN 0 0 0 0 0 0 0 0 1

4   Pass
x = [2 NaN 3 5 NaN; 1 NaN 4 9 NaN; 8 pi 7 6 pi; 7 eps 8 5 eps]; y_correct = [2 NaN 3 5; 1 NaN 4 9; 8 pi 7 6; 7 eps 8 5]; assert(isequalwithequalnans(unique_with_nan(x),y_correct))

y = 7.0000 8.0000 1.0000 2.0000 0.0000 3.1416 Inf Inf 8.0000 7.0000 4.0000 3.0000 5.0000 6.0000 9.0000 5.0000 0.0000 3.1416 Inf Inf y = 7.0000 8.0000 1.0000 2.0000 0.0000 3.1416 Inf Inf 8.0000 7.0000 4.0000 3.0000 5.0000 6.0000 9.0000 5.0000 y = 2.0000 Inf 3.0000 5.0000 1.0000 Inf 4.0000 9.0000 8.0000 3.1416 7.0000 6.0000 7.0000 0.0000 8.0000 5.0000 y = 2.0000 NaN 3.0000 5.0000 1.0000 NaN 4.0000 9.0000 8.0000 3.1416 7.0000 6.0000 7.0000 0.0000 8.0000 5.0000

Suggested Problems

More from this Author71

Community Treasure Hunt

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

Start Hunting!