## I am able to read the netcdf file format. But how to calculate average? Suppose I have to calculate the average from 1st January to 5th January, then again 6th January to 10th January and so on.....Below is the program to read the values.

### Girija (view profile)

on 20 Aug 2014
Latest activity Answered by Ashish Uthama

on 20 Aug 2014

### Ashish Uthama (view profile)

ncid = netcdf.open('data.nc', 'NC_NOWRITE');
[ndim,nvar,natt,unlim] = netcdf.inq(ncid);
[dimname,dimlength]=netcdf.inqDim(ncid,0);
[dimname,dimlength]=netcdf.inqDim(ncid,1);
[dimname,dimlength]=netcdf.inqDim(ncid,2);
[dimname,dimlength]=netcdf.inqDim(ncid,3);
netcdf.inqDim(ncid,dimids);
[varname, xtype, dimid, natt] = netcdf.inqVar(ncid, 0);
[varname, xtype, dimid, natt] = netcdf.inqVar(ncid, 1);
[varname, xtype, dimid, natt] = netcdf.inqVar(ncid, 2);
[varname, xtype, dimid, natt] = netcdf.inqVar(ncid, 3);
[varname, xtype, dimid, natt] = netcdf.inqVar(ncid, 4);
[varname, xtype, dimid, natt] = netcdf.inqVar(ncid, 5);
lat = netcdf.getVar(ncid,0,0,72);
lon = netcdf.getVar(ncid,1,0,144);
precJanuary = netcdf.getVar(ncid,4,[0 0 0 0],[144 72 1 1]); % for january data
But how to calculate average? Suppose I have to calculate the average from 1st January to 5th January, then again 6th January to 10th January and so on.....
[Edited for code formatting -AU]

on 20 Aug 2014