Fill missing data in timeseries object
1 view (last 30 days)
Show older comments
Hi everyone,
I am working with timeseries (minute-based, so each day should have 1440 data points and corresponding time values - I use the datenum format).
Unfortunately, some days lack some data points and I would like to identify these spots by analyzing the time vector and then have Matlab fill in the missing time and a "0" as the data point. To keep processing time low, I would prefer to continue working with the datenum format and use the "addsample"-function.
Maybe someone has an idea on how to tackle this problem?
Many thanks in advance!
1 Comment
jgg
on 15 Jan 2016
It would help if you explained your data a little more; how is it set up?
For example, if you actual time is like at = [1,2,4,5] for a 5 minute interval, you could do something like this:
observed_times = [1,2,4,5];
observed_data = [14.1,12.2,3.4,1.1];
t = [1:5];
[~,ind] = ismember(t,observed_times);
impute_data = [NaN,observed_data];
ind = ind + 1;
corr_data = impute_data(ind);
Your new time series would be t,|corr_data|. I used NaN here instead of a zero because you might actually have zeroes here, but you can easily change this.
Answers (0)
See Also
Categories
Find more on Dates and Time 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!