How to replace numbers (-999) for NaN in a dataset?
7 Ansichten (letzte 30 Tage)
I have a large dataset with variables containing -999. I want to change those numbers to NaN but it is not working...
...this is the error I get:
Undefined operator '==' for input arguments of type 'dataset'.
Thank you for your help!
Guillaume am 12 Mär. 2018
Note: datasets have been deprecated for a while. Consider using tables instead.
A dataset is a collection of variables. So you have to do your replacement per variable. e.g.
yourdataset.somevariable(yourdataset.somevariable == -999) = nan;
%same for all variables
Another option would be to use replacedata. For it to work you'll have to create an m file for a replacement function:
function X = datasetreplace(X)
X(X == -999) = nan;
You can then do:
newdataset = replacedata(yourdataset, @datasetreplace)