필터 지우기
필터 지우기

Transfer Quarterly dates to Monthly

조회 수: 2 (최근 30일)
King To Leung
King To Leung 2022년 8월 1일
댓글: King To Leung 2022년 8월 1일
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