Hi, all! I have a array of monthly log returns from 1962 to 2016, I wish to extract the monthly values, every 12th value.

1 view (last 30 days)
Can andybody assist with this issue? How do I extract every 12th value?
Thanks!

Accepted Answer

KL
KL on 13 Oct 2017
Edited: KL on 13 Oct 2017
data = 1:144; %sample data
data_mean = arrayfun(@(a,b) mean(data(a:b)),1:12:numel(data),12:12:numel(data))
  7 Comments
Ola Sveen
Ola Sveen on 16 Oct 2017
KL, i´m sorry for the late reply. Many thanks for your assistance. The task have developed some, and we want to sum every 12th value like you prepose, du you know how this is done?

Sign in to comment.

More Answers (1)

Ola Sveen
Ola Sveen on 13 Oct 2017
Edited: Ola Sveen on 13 Oct 2017
Thx KL!
Now I would like to extract annual log returns from a dataset containing prices and dates. Do you know how to solve this? I have calculated the monthly log returns, how do I calculate the annual. I guess I need some sort of loop function, taken in consideration the formula for log return.
many thanks

Categories

Find more on Historical Contests in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!