How to take monthly average from table?

5 次查看(过去 30 天)
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.

回答(1 个)

KSSV
KSSV 2022-4-16

Community Treasure Hunt

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

Start Hunting!

Translated by