How can I use retime to convert to monthly time frequency, and display the data for end of month dates?
8 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2019-11-26
回答: MathWorks Support Team
2020-3-4
I would like to alter my timetable to display end-of-month dates, rather than start-of-month dates. How can I use the retime function to achieve this?
采纳的回答
MathWorks Support Team
2019-11-26
The "retime" function (used with timetables) operates differently than the "tomonthly" function used with TimeSeries data, as it displays the new monthly frequency table with start-of-month datetimes rather than end-of-month datetimes.
The trick is to use the following version of retime:
TT2 = retime(TT1,newTimes,method)
and pass in the end of month date times as the variable "newTimes".
Attached is a script ("test_script.m") which demos how to create a time-series time table and how to convert them to monthly time-series and timetable respectively and the differences between the two.
The "retime" function is extensive and can be used for a variety of functions that were used to manipulate TimeSeries objects. The documentation for "retime" can be found here:
The general workflow for converting code that uses time series over to timetables can be found here:
You might have to use additional functions that operate on "datetime" arrays to get to the final result (Eg - "eomdate" in attached code).
A full list of functions that operate on "datetime" arrays can be found here:
0 个评论
更多回答(0 个)
另请参阅
类别
在 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!