Remove the two elements next to NaN value - MATLAB Cody - MATLAB Central

Problem 690. Remove the two elements next to NaN value

Difficulty:Rate

The aim is to remove the two elements next to NaN values inside a vector.

For example:

 x = [6 10 5 8 9 NaN 23 9 7 3 21 43 NaN 4 6 7 8]

The output y will be:

 y = [6 10 5 8 9 7 3 21 43 7 8]

Nan values and the 2 next elements after the NaN (23-9 and 4-6) have been removed.

There will be always NaN values in the input vector followed by at least 2 integers.

Solution Stats

41.66% Correct | 58.34% Incorrect
Last Solution submitted on May 07, 2025

Problem Comments

Solution Comments

Show comments
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
3

Group

Indexing I Image
Indexing I
  • 27 Problems
  • 237 Finishers

Problem Recent Solvers662

Community Treasure Hunt

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

Start Hunting!
Go to top of page