Cody

# Problem 42669. replace nan values iteratively.

Solution 2159552

Submitted on 14 Mar 2020 by Asif Newaz
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; 4; 6; nan; nan; nan; 10]; y_correct = [2; 4; 6; 8; 9; 9.5; 10]; assert(isequal(replaceNaN(x),y_correct))

2   Pass
x = [1; 2; 3; 4; nan; 6]; y_correct = [1; 2; 3; 4; 5; 6]; assert(isequal(replaceNaN(x),y_correct))

3   Pass
x = [360; nan; nan; nan; nan; 120]; y_correct = [360; 240; 180; 150; 135; 120]; assert(isequal(replaceNaN(x),y_correct))

4   Pass
x = [2; 4; 6; nan; nan; nan; 10; 360; nan; nan; nan; nan; 120]; y_correct = [2; 4; 6; 8; 9; 9.5; 10; 360; 240; 180; 150; 135; 120]; assert(isequal(replaceNaN(x),y_correct))

5   Pass
x = [2; nan; 4; 10; nan; 12; -20; nan; -40]; y_correct = [2; 3; 4; 10; 11; 12; -20; -30; -40]; assert(isequal(replaceNaN(x),y_correct))

6   Pass
x = [2; nan; nan; 6]; y_correct = [2; 4; 5; 6]; assert(isequal(replaceNaN(x),y_correct))

7   Pass
x = [2; nan; 8; 10; nan; 12; -20; nan; -40]; y_correct = [2; 5; 8; 10; 11; 12; -20; -30; -40]; assert(isequal(replaceNaN(x),y_correct))