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 visualización (últimos 30 días)
Can andybody assist with this issue? How do I extract every 12th value?
Thanks!
  1 comentario
Ola Sveen
Ola Sveen el 13 de Oct. de 2017
Editada: Ola Sveen el 13 de Oct. de 2017
I also wish to take the average of every 12th value. Eg. mean of 1-12, mean 12-24, mean 24 - 36. Anybody?

Iniciar sesión para comentar.

Respuesta aceptada

KL
KL el 13 de Oct. de 2017
Editada: KL el 13 de Oct. de 2017
data = 1:144; %sample data
data_mean = arrayfun(@(a,b) mean(data(a:b)),1:12:numel(data),12:12:numel(data))
  7 comentarios
Ola Sveen
Ola Sveen el 16 de Oct. de 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?

Iniciar sesión para comentar.

Más respuestas (1)

Ola Sveen
Ola Sveen el 13 de Oct. de 2017
Editada: Ola Sveen el 13 de Oct. de 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

Categorías

Más información sobre Historical Contests en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by