Effacer les filtres
Effacer les filtres

mmyyy date to matlab date

3 vues (au cours des 30 derniers jours)
V
V le 8 Août 2014
Modifié(e) : Sean de Wolski le 8 Août 2014
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

Réponse acceptée

Sean de Wolski
Sean de Wolski le 8 Août 2014
Modifié(e) : Sean de Wolski le 8 Août 2014
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)

Plus de réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 8 Août 2014
d=[199001, 199002, 199003 ]
a=arrayfun(@(x) datenum(num2str(x),'yyyymm'),d)
  2 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 8 Août 2014
Modifié(e) : Azzi Abdelmalek le 8 Août 2014
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
Azzi Abdelmalek
Azzi Abdelmalek le 8 Août 2014
There are no days in your data, look at your question, (yyyy/mm)

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by