Effacer les filtres
Effacer les filtres

Transfer Quarterly dates to Monthly

2 vues (au cours des 30 derniers jours)
King To Leung
King To Leung le 1 Août 2022
Commenté : King To Leung le 1 Août 2022
Hi all,
I extracted quarterly data for eps in matlab data form (i think datevec is needed). from 31/3/1992, 30/6/1992, 30/9/1992,....31/12/2021.
Earnings per share data is only available on these dates and I need to turn it to monthly data
For example
the eps of 31/3/1992 is 1.2
the eps of 30/6/1992 is 1.3
the eps of 30/9/1992 is 1.4
the eps of 31/12/1992 is 1.5
I want to result to be like this
31/1/1992 1.2
28/2/1992 1.2
31/3/1992 1.2
30/4/1992 1.3
31/5/1992 1.3
30/6/1992 1.3
31/7/1992 1.4
31/8/1992 1.4
30/9/1992 1.4
31/10/1992 1.5
30/11/1992 1.5
31/12/1992 1.6
Thank you very much!!!

Réponse acceptée

Chunru
Chunru le 1 Août 2022
Modifié(e) : Chunru le 1 Août 2022
% Your data
dtstr = ["31/3/1992"
"30/6/1992"
"30/9/1992"
"31/12/1992"];
x = [1.2 1.3 1.4 1.5]';
% Convert from quarter to months
dt = datetime(dtstr, 'InputFormat', 'd/M/yyyy');
dt = dt + calmonths(-2:0);
dt = dt';
dt =eomdate(dt(:));
x = repmat(x', 3, 1);
x = x(:);
%whos
T = table(dt, x)
T = 12×2 table
dt x ___________ ___ 31-Jan-1992 1.2 29-Feb-1992 1.2 31-Mar-1992 1.2 30-Apr-1992 1.3 31-May-1992 1.3 30-Jun-1992 1.3 31-Jul-1992 1.4 31-Aug-1992 1.4 30-Sep-1992 1.4 31-Oct-1992 1.5 30-Nov-1992 1.5 31-Dec-1992 1.5

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time 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