Replacing missing data in timetable with values from another dataset
Show older comments
Hi all - I have a reasonably large time-series dataset (57777-by-20) of daily mean temperature for 1980 to present day, recorded from a weather station in Denmark. Within the time-series there are several large gaps in the coverage (> 1-2 months) due to maintenance and servicing of the weather station.
The gaps are too large to consider interpolating between missing data, so I would like to replace the missing values with data recorded from a temporary weather station, that was sited near the main station during periods when it was unable to operate. Having visually and statistically investigate the similarity between the two datasets, this seems a sound approach.
I've imported both datasets from .txt files, converted them to timetables, and located and replaced missing data with nan's.
However, I've been unable to successfully replace the nan's with like-for-like data from the secondary dataset (i.e., replacing with data from the exact same datetime). The datasets cover different temporal ranges, so indexing and replacing cells between the data has not worked (see code below).
I think I'm looking for a similar method but indexing both the rowtimes and the missing data from the temperature variable.
It would be great to hear from anyone with a solution to this problem, or with a similar method for replacing missing data within a time-series with values from a different dataset?
% index to find cells containing no-data
[idx] = find(data1.Temp == 999 | data1.Temp == -999);
% replace no-data vaules with nan
data1.Temp(idx) = nan;
% index to find nan's
idx = isnan(data1.Temp);
% DOES NOT WORK SIMPLY REPLACING NAN'S BY INDEXING THE TWO DATASETS,
% AS THEY COVER DIFFERENT TEMPORAL RNAGES
data1.Temp(idx) = data2.Temp(idx);
Accepted Answer
More Answers (0)
Categories
Find more on Timetables 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!