Cody

# Problem 300. Remove NaN ?

Solution 1971758

Submitted on 11 Oct 2019 by Cao Van Cuong
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 = magic(3);x(2,[1 3])= NaN; y_correct = [8 1 6;4 9 2]; assert(isequal(removeNaN(x),y_correct))

ssh = 1 b = 2 ssh = 2 b = 2 2 d = 1 0 3 B = 8 1 6 B = 8 1 6 4 9 2

2   Pass
x = [magic(4) ones(4,1)]; x(4,5) = NaN;x(3,2) = Inf;x(3,1)=NaN; y_correct = x(1:2,:); assert(isequal(removeNaN(x),y_correct))

ssh = 1 b = 3 ssh = 2 b = 3 4 d = 1 2 0 4 d = 1 2 0 0 B = 16 2 3 13 1 B = 16 2 3 13 1 5 11 10 8 1

3   Pass
x = ones(4);x(3,3)=NaN; y_correct = ones(3,4); assert(isequal(removeNaN(x),y_correct))

ssh = 1 b = 3 d = 1 2 0 4 B = 1 1 1 1 B = 1 1 1 1 1 1 1 1 B = 1 1 1 1 1 1 1 1 1 1 1 1

4   Pass
x = [1; NaN]; y_correct = [1]; assert(isequal(removeNaN(x),y_correct))

ssh = 1 b = 2 d = 1 0 B = 1

5   Pass
x = NaN; assert(isempty(removeNaN(x)))

ssh = 1 b = 1 d = 0

6   Pass
x = [1:10 NaN]; assert(isempty(removeNaN(x)))

ssh = 1 b = 1 d = 0

7   Pass
x = [1:10 NaN]'; y_correct = [1:10]'; assert(isequal(removeNaN(x),y_correct))

ssh = 1 b = 11 d = 1 2 3 4 5 6 7 8 9 10 0 B = 1 B = 1 2 B = 1 2 3 B = 1 2 3 4 B = 1 2 3 4 5 B = 1 2 3 4 5 6 B = 1 2 3 4 5 6 7 B = 1 2 3 4 5 6 7 8 B = 1 2 3 4 5 6 7 8 9 B = 1 2 3 4 5 6 7 8 9 10