convert monthly data from daily data series
3 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Kelly Kearney
on 24 Jun 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);
0 Comments
More Answers (0)
See Also
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!