mmyyy date to matlab date
1 次查看(过去 30 天)
显示 更早的评论
Hi there.
I have a column vector with dates on the following format: yyyymm
E.g. [199001, 199002, 199003 ...]'
They are all the last trading day of the month.
How can I transform them into matlab serial date numbers?
Thanks
0 个评论
采纳的回答
Sean de Wolski
2014-8-8
编辑:Sean de Wolski
2014-8-8
x = [199001, 199012, 199003]';
% Calculate year and month
mm = rem(x,100);
yyyy = (x-mm)./100;
% get last business day (Financial Toolbox Req'd)
last_bus_day = lbusdate(yyyy,mm)
0 个评论
更多回答(1 个)
Azzi Abdelmalek
2014-8-8
d=[199001, 199002, 199003 ]
a=arrayfun(@(x) datenum(num2str(x),'yyyymm'),d)
2 个评论
Azzi Abdelmalek
2014-8-8
编辑:Azzi Abdelmalek
2014-8-8
V commented
Dear Azzi, Thank you for your answer. However, the code you mentioned gives me the first day of month and not the last trading day. Thanks
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Time Series Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!