MATLAB Answers

eliminating NaN values from an array

7 views (last 30 days)
KalMandy
KalMandy on 10 Nov 2016
Answered: Steven Lord on 19 Jan 2020
Hi, does someone know how to eleiminate NaN values from an array? For example I have an array [NaN 0.6451 NaN 0.8339 0.8015 ], I want to make it [0.6451 0.8339 0.8015 ]

  0 Comments

Sign in to comment.

Accepted Answer

Guillaume
Guillaume on 10 Nov 2016
newarray = originalarray(~isnan(originalarray))

  1 Comment

Sign in to comment.

More Answers (2)

Sara Sahraoui
Sara Sahraoui on 18 Jan 2020
Comment eliminer les nans sur data

  0 Comments

Sign in to comment.


Steven Lord
Steven Lord on 19 Jan 2020
In newer releases you can use rmmissing to remove missing data (NaN for double and single precision data, <undefined> for categorical arrays, etc.) There are other functions for working with missing data like fillmissing listed on this documentation page.

  0 Comments

Sign in to comment.

Sign in to answer this question.