replace nan values iteratively. - MATLAB Cody - MATLAB Central

Problem 42669. replace nan values iteratively.

Difficulty:Rate

replace nan values with the average of two neighbour non-nan value iteratively as follow;

 x = [2; 4; 6; nan; nan; nan; 10];
 x = [2; 4; 6;   8; nan; nan; 10];
 x = [2; 4; 6;   8;   9; nan; 10];
 x = [2; 4; 6;   8;   9; 9.5; 10];   

Solution Stats

62.32% Correct | 37.68% Incorrect
Last Solution submitted on Nov 13, 2025

Problem Comments

Solution Comments

Show comments
Join Cody Contest 2025 — Have Fun and Win Prizes!
...
We’re excited to invite you to Cody Contest 2025! 🎉 Pick a team,...

Problem Recent Solvers28

Suggested Problems

More from this Author92

Problem Tags

nan

Community Treasure Hunt

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

Start Hunting!