Transfer Quarterly dates to Monthly

3 visualizaciones (últimos 30 días)
King To Leung
King To Leung el 1 de Ag. de 2022
Comentada: King To Leung el 1 de Ag. de 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!!!

Respuesta aceptada

Chunru
Chunru el 1 de Ag. de 2022
Editada: Chunru el 1 de Ag. de 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

Más respuestas (0)

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by