convert monthly data from daily data series

조회 수: 7 (최근 30일)
Peihong
Peihong 2013년 6월 24일
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

채택된 답변

Kelly Kearney
Kelly Kearney 2013년 6월 24일
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);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by