How can I find and put zero for missinf data in a time series?

3 ビュー (過去 30 日間)
Andrea
Andrea 2012 年 8 月 21 日
Hi all
I have a 30 years of hourly data. Some of the data are missing. It means that I do not have data for example for 1 PM and 2 PM of 12th of JAN. But the missing value are a lot and scattered through the 3 years. How can find them and put zero instead of them in a bigger matrix? I have 5 vectors (years, month, days, hour, values). Some of the hours in some days are missing. We can see them by looking at the data but how can I detect them by MATLAB and increase the size of my matrix by putting zeros instead of them?
I'll appreciate in advance, Andrea
  1 件のコメント
per isakson
per isakson 2012 年 8 月 21 日
Do you really want to replace missing data with zero?

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2012 年 8 月 21 日
For each time that you do have, calculate an hour number (an integral value) starting from 1 for the first time-point. Then
ExpandedData = accumarray(HourNumber(:), DataValues(:));
The result will be a column vector in which the row number corresponds to the hour number, and the entry for the row corresponds to the data value for that time, and there are 0's for any missing times.
Note: with the call done this way, if there happen to be multiple entries with the same hour number, the entries would be summed. Changing to calculate the mean instead is quite simple -- add the arguments [], @mean to the call.
  2 件のコメント
Andrea
Andrea 2012 年 8 月 21 日
Thanks, but still I have question. What is the HourNumber? is it something from 1:24 and repeat again?
Walter Roberson
Walter Roberson 2012 年 8 月 21 日
The hour numbers should be consecutive, 25 for the 25th hour, and so on.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by