i have this Matrix, consisting of 3 columns: Column 1: long Column 2: lat Column 3: year
lets say 97x281x15,
I want to make average for each year. so i want the result is 1x15, or 15x1
or kind of look like this
YEAR / DATA AVERAGE
1995 25.786
1996 25.686
1997 25.746
1998 25.686
and so on
Thank you for your suggestions.

2 comentarios

Ive J
Ive J el 12 de Jul. de 2021
If you're matrix has 3 columns, the size should be of size rowX3, can you upload a subset of your data (mat/delimited file)?
sky walker
sky walker el 12 de Jul. de 2021
here is my file, thanks for your time

Iniciar sesión para comentar.

 Respuesta aceptada

Matt J
Matt J el 12 de Jul. de 2021
Editada: Matt J el 12 de Jul. de 2021

0 votos

In recent Matlab,
mean(SSTmonth,[1,2])
In older Matlab,
mean(reshape(SSTmonth,[],15),1)

3 comentarios

sky walker
sky walker el 12 de Jul. de 2021
thanks for your answer, im using matlab R2018a
it gave me error
Error using reshape
Product of known dimensions, 15, not divisible into total number of elements, 681425.
Error in test (line 93)
data = mean(reshape(SSTmonth,[],15),1);
Matt J
Matt J el 12 de Jul. de 2021
Editada: Matt J el 12 de Jul. de 2021
Apparently your array is not 97x281x15 because if so there is no way that 15 would not be divisible into the number of elelments.
sky walker
sky walker el 12 de Jul. de 2021
oh sorry, my bad. thanks for your help.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 12 de Jul. de 2021

Comentada:

el 12 de Jul. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by