Transfer Quarterly dates to Monthly

2 次查看(过去 30 天)
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!!!

采纳的回答

Chunru
Chunru 2022-8-1
编辑:Chunru 2022-8-1
% 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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by