Remove any continuous NaNs that appear in the array -
%Example 1
input = [1 NaN 2 NaN NaN 3 NaN NaN NaN]
output = [1 NaN 2 3]
%Example 2
input = [NaN NaN NaN 2 NaN 3 NaN 5 NaN 7 NaN NaN]
output = [2 NaN 3 NaN 5 NaN 7]
%Example 3
input = [-1 NaN NaN NaN NaN 0 NaN NaN NaN NaN NaN NaN 1]
output = [-1 0 1]
However, there is a restriction on the problem i.e. only vectorized solutions will be accepted. Check the test suite for banned functions.
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers12
Suggested Problems
-
Determine whether a vector is monotonically increasing
23335 Solvers
-
Find relatively common elements in matrix rows
2157 Solvers
-
Replace all zeros and NaNs in a matrix with the string 'error'
104 Solvers
-
Sum of diagonals elements of a matrix
233 Solvers
-
532 Solvers
More from this Author44
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!