Im pretty new to matlab. can any one assist me with how to make a loop to calculate average ?

2 views (last 30 days)
>> url =tasmax_A2.20010101-21001231.nc
>> nc=ncgeodataset(url);
>> nc.dimensions('tasmax')
ans =
'time'
'lat'
'lon'
>> nc.netcdf
ans =
netcdf tasmax_A2.20010101-21001231.nc {
dimensions:
lon = 144;
lat = 90;
time = UNLIMITED; // (36500 currently
bnds = 2;
variables:
double lon_bnds(lon=144, bnds=2);
double lat_bnds(lat=90, bnds=2);
double time_bnds(time=36500, bnds=2);
float tasmax(time=36500, lat=90, lon=144);
>> nc.variables
ans =
'lon_bnds'
'lat_bnds'
'time_bnds'
'tasmax'
'lon'
'lat'
'time'
'height'
>> t=nc{'tasmax'}(1,1:end,1:end);
now the question is 't' is a function of time so i think it can be written as ti=nc{'tasmax'}(i,1:end,1:end)
by changing the values of i i get daily data from 2001 01 01 to 2100 12 31. i cross checked the data for few days with panoply which matches the output
Now, how can i write a loop to calculate monthly average and annual average for any particular year?
can any one assist me?
Thanks in advance
  4 Comments
Bathula vardhan
Bathula vardhan on 20 Jul 2016
withs lots of exploring i did this
>> tavg=squeeze(mean(nc{'tasmax'}(1:365,1:end,1:end)));
this one surely gave me average to one year data. can any one tell me how to calculate this for every year ?

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!