Fill missing data in timeseries object

6 次查看(过去 30 天)
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 个评论
jgg
jgg 2016-1-15
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by