extract numbers from time series
2 次查看(过去 30 天)
显示 更早的评论
Have a time series from 1 to 156. Want to extract the values from 1:6, then from (1+12) : (6+12), etc into a new variable. How to go about.
6 个评论
Adam Danz
2018-8-13
Ok. If the numbers are serial date numbers that matlab recognizes, my solution should work well. Otherwise, we'd just need to convert them to a format that Matlab recognizes which should be fairly simple.
采纳的回答
Adam Danz
2018-8-13
I don't know what format your dates are in but this can be adapted to any format. I assume your matrix is named 'data' and the dates are in the 5th column.
% Get the month number for each date
monthNum = month(data(:,5));
% Logical index of rows that are between May and October
monthIdx = ismember(monthNum, [5:10]);
% Extract your data for these months
data(monthIdx, :)
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!