shifting time in timetable
15 ビュー (過去 30 日間)
古いコメントを表示
i want to shift this timetable for 1 day it means i want this, start from 03-jan-2018 regardless of hours
0 件のコメント
採用された回答
dpb
2018 年 10 月 25 日
Not sure what the "want" really means--the present time just a day later for each observation or what, precisely?
On the presumption that's the correct guess, then
TT.Time=TT.Time+1;
2 件のコメント
Peter Perkins
2018 年 10 月 31 日
This works, but for two reasons I would recommend adding caldays(1) rather than just 1.
1) For backwards compatibility reasons, 1 is interpreted as a datenum, i.e. days(1). But that's perhaps not obvious to someone reading the code at some later time.
2) Getting in the habit of using caldays for calendar arithmetic is a good idea, because someday, you're going to be working with zoned datetimes, and adding a day to a Sat that happens to be the day before a DST shift. days(1) means "exactly 24 hours", which probably isn't what you'd want, while caldays(1) means "one calendar day", which probably is.
>> dt = datetime(2018,11,3,14,0,0,'TimeZone','America/New_York')
dt =
datetime
03-Nov-2018 14:00:00
>> dt + days(1)
ans =
datetime
04-Nov-2018 13:00:00
>> dt + caldays(1)
ans =
datetime
04-Nov-2018 14:00:00
days is mostly intended as a shorthand for "24 hours" when you are working with "exact times" and durations.
dpb
2018 年 10 月 31 日
Good points, Peter.
I didn't have a klew as to what the OP was asking so was hoping for a response as to what the desire really was so I just took the shortcut to try to begin the conversation. Hadn't realized OP even came back until saw your comment just now...
その他の回答 (1 件)
jonas
2018 年 10 月 25 日
編集済み: jonas
2018 年 10 月 25 日
Simply shifting the time without affecting the data
TT.Time = dateshift(TT.Time,'start','day')
Changing the format (hiding the time of day)
TT.Time.Format = 'dd-MMM-yyyy'
Calculating a daily average
TT2 = retime(TT,'daily','mean')
These are the answers to three possible interpretations of your question. Perhaps you could describe your problem a bit better next time.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Calendar についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!