Filter löschen
Filter löschen

Transfer Quarterly dates to Monthly

2 Ansichten (letzte 30 Tage)
King To Leung
King To Leung am 1 Aug. 2022
Kommentiert: King To Leung am 1 Aug. 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!!!

Akzeptierte Antwort

Chunru
Chunru am 1 Aug. 2022
Bearbeitet: Chunru am 1 Aug. 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

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by