How to split data into several segments so that in each segment, the number of NaN is not more than a certain value.
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Adib Yusof
am 15 Jan. 2018
Beantwortet: Image Analyst
am 15 Jan. 2018
I have a large data which contains around 6,500,000+ data points. I need to split/divide my data into several segments so that in each segment, the number of consecutive NaN is not more than 18,000. What should I try? Thanks.
1 Kommentar
Rik
am 15 Jan. 2018
Is that the only requirement? If so, you can simply use isnan and a bit of code.
Akzeptierte Antwort
Image Analyst
am 15 Jan. 2018
Try this (just off the top of my head):
data = rand(1, 6500000);
segmentLength = 1000000; % Whatever...
nansPerSegment = 30000; % Whatever...
for k = 1 : segmentLength : length(data)
lastIndex = min(length(data), k + segmentLength - 1);
thisData = data(k:lastIndex);
numElements = numel(thisData);
nanLocations = k + randperm(numElements, nansPerSegment) - 1;
data(nanLocations) = nan;
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!