Get data from timeseries object for every day contained in the timeseries object
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi everyone, I have another question related to timeseries. I created a timeseries, whereas the timevector is in the datenum format. Specifically, the format I have is for example:
7.359655423611111e+05 % which corresponds to second specific data, e.g. 01-Jan-2015 10:15:00
The timeseries contains minute-wise data, hence I have 1440 data points for each day. What I would like to do now is loop through the timeseries and extract the 1440 data points for each day and put them into a cell array.
I think the logic would be to identify the unique dates among the time vector and then use the getsampleusingtime-function in a loop that may look something like this:
dates = unique(ts.Time); % whereas ts is the timeseries
dailyData = cell([1 length(dates)]) % initialize the cell array to store the data from the timeseries
for i = 1:length(dates)
dailyData{1,i} = getsampleusingtime(ts,dates(i),'AllowDuplicateTimes, true')
end
The problem I am running into is that I
- Don't know how to construct the unique dates array from the full datenum time vector which also contains the h,m,s-info
- Don't know how to query against the ts with the unique dates, because even if I had the unique dates separated, the function is likely not to provide any matches because it is also looking for a match of the h,m,s-information
Can anyone help me out? Any help is much appreciated!
댓글 수: 3
jgg
2016년 1월 16일
I mean, if you have this, you should be able to do like this:
times = [735965.542361111; 735965.542372685; 735965.542384259; ...
735966.542361111; 735966.542372685];
T = datetime(datestr(times));
days = unique(T.Day);
ind = ismember(T.Day,days(1)); %get the first day
times(ind)
You can use the Day Year properties to select data with the properties you want. If you loop over the days in days you'll iteratively select every set of observations for that day. If the day alone doesn't uniquely identify this, you'll have to add on the month, year, etc, but it's the same process.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Time Series Events에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!