Azzera filtri
Azzera filtri

convert monthly data from daily data series

4 visualizzazioni (ultimi 30 giorni)
Dear Friend, I have a time series of SP500 daily prices since 1950. I want to find out the monthly end prices, how can I handle this problem? I am aware there is one function convertto, which uses financial times series object as input arguement. It will be better not to use this function. there is also another function eomday, but this function may also have problems if I need to handle many time series data, some are closing last calender day, some are closing last buz day. it may cause problems. Is there some general method to handle this? thanks

Risposta accettata

Kelly Kearney
Kelly Kearney il 24 Giu 2013
Assuming t is a vector of datenumbers and x is your corresponding data, the following code will return the last instance of each year-month combo found in your dataset:
dv = datevec(t);
[unq, ia] = unique(dv(:,1:2), 'rows', 'last');
tlast = t(ia);
xlast = x(ia);

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by