How can I use retime to convert to monthly time frequency, and display the data for end of month dates?

8 ビュー (過去 30 日間)
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
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 件)

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by