MATLAB Answers

average for each year

1 view (last 30 days)
sky walker
sky walker on 12 Jul 2021
Commented: sky walker on 12 Jul 2021
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 Comments
sky walker
sky walker on 12 Jul 2021
here is my file, thanks for your time

Sign in to comment.

Accepted Answer

Matt J
Matt J on 12 Jul 2021
Edited: Matt J on 12 Jul 2021
In recent Matlab,
mean(SSTmonth,[1,2])
In older Matlab,
mean(reshape(SSTmonth,[],15),1)
  3 Comments
sky walker
sky walker on 12 Jul 2021
oh sorry, my bad. thanks for your help.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!