this file consists of 6 columns: the the third,the fourth,the fifth and the sixth include values such as (99999,9) and (99,9900) ; these values i want to replace them by the following word (NAN) not a number.....please tell me the code for doing this...........the name of the file is space......the name of the third column is y3......the name of the fourth column is y4........the name of the fifth column is y5......the name of the sixth column is y6.. i hope you tell me the code for replacing 99999,9 and 99,9900 by NAN (not a number).
how i can replace (99999,9) and (99,9900) in a column by NAN?
1 view (last 30 days)
Show older comments
astrogeophysicist mohamed
on 26 Mar 2020
Commented: Cris LaPierre
on 26 Mar 2020
this file consists of 6 columns: the the third,the fourth,the fifth and the sixth include values such as (99999,9) and (99,9900) ; these values i want to replace them by the following word (NAN) not a number.....please tell me the code for doing this...........the name of the file is space......the name of the third column is y3......the name of the fourth column is y4........the name of the fifth column is y5......the name of the sixth column is y6.. i hope you tell me the code for replacing 99999,9 and 99,9900 by NAN (not a number).
Accepted Answer
Cris LaPierre
on 26 Mar 2020
Edited: Cris LaPierre
on 26 Mar 2020
% Create a row vector and replace all instances of -99
% with the standard missing value for double data types, NaN.
A = [0 1 5 -99 8 3 4 -99 16];
B = standardizeMissing(A,-99)
7 Comments
Cris LaPierre
on 26 Mar 2020
You must be trimming the header lines out of your file. If I run that code on the space.txt file attached to this question, I get the following error message:
Error using load
Unable to read file 'space.txt'. Input must be a MAT-file or an ASCII file containing numeric data with same number of columns in each row.
Cris LaPierre
on 26 Mar 2020
Once your data is in MATLAB, use standardizeMissing to replace the specified value with NaN. You'll need to do this for each variable. Here is the code for y3.
y3 = standardizeMissing(y3,99999.9);
More Answers (0)
See Also
Categories
Find more on NaNs in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!