How to skip rows when loading data from a netcdf file

조회 수: 10 (최근 30일)
Celine Boulenger
Celine Boulenger 2015년 10월 3일
댓글: Celine Boulenger 2015년 10월 3일
Hi, I am reading temperature data from a netcdf file that is a (720x360x744) matrix (it depends on longitude, latitude and time). For the latitude and longitude I only use one row depending on which city I am looking at. The temperature is measured several times a day for one month but I only want to get one measure per day. Is there a way for me to skip some rows in the last column? I want only every 24 rows, I want row 25,49,73 etc. not the ones in between.
My code so far is :
[varname, xtype, varDimIDs, varAtts] = netcdf.inqVar(Ncid111,3);
varid = netcdf.inqVarID(Ncid111,varname);
airtemp = netcdf.getVar(Ncid111,varid');
mydata=airtemp(220,114,1:744)
This gives me the whole TIME column (measures 1 through 744) but I only want every 24th measure.
Thank you for your help!!

채택된 답변

Kelly Kearney
Kelly Kearney 2015년 10월 3일
Take a look at the start, count, and stride inputs that are associated with most netcdf methods, including getVar. For example,
mydata = netcdf.getVar(Ncid111, varid, [220 114 1], [1 1 Inf], [1 1 24]);
What version of Matlab are you running? If it's relatively recent, you can simplify things by using ncread:
mydata = ncread('file.nc', varname, [220 114 1], [1 1 Inf], [1 1 24]);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by