Effacer les filtres
Effacer les filtres

How to take monthly average from table?

4 vues (au cours des 30 derniers jours)
Keegan Carvalho
Keegan Carvalho le 16 Avr 2022
Réponse apportée : KSSV le 16 Avr 2022
Hi all!
I have an excel file (attached) - data.xlsx. The first column "date" has values stored as "yyyymmdd" format for each grid cell in a netcdf file. dur - duration and int-intensity.
Now I wanted to first convert those date values to month-year formats (eg. Jan - 1990, Feb - 1990...) and find the monthly average for "dur" and "mean". I started off with the following code, but ended up getting wrong values:
data=readtable("data.xlsx");
datar=datevec(num2str(data{1,:}),'yyyymmdd');
dv = datevec(data.date);
data.Year = dv(:,1);
data.Month = dv(:,2)
I've read about varfun, but I'm still working my way around this. Appreciate any help with my problem.

Réponses (1)

KSSV
KSSV le 16 Avr 2022

Community Treasure Hunt

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

Start Hunting!

Translated by