convert monthly data from daily data series
조회 수: 7 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!