How do I take the average SST over a specific region and date.

5 views (last 30 days)
I provided the code I have done so far, I have no experience coding. I'm trying to figure out how to take the average sst from 01-Jan-1984 and 01-Dec-2014 within Latitude: 60N to 30N and Longitude 150 to 240. This is for a time series. Please help.

Answers (1)

ANKUR KUMAR
ANKUR KUMAR on 2 Dec 2017
lat=ncread('sst.mnmean.nc','lat'); %for reading the lat variable from .nc file
lon=ncread('sst.mnmean.nc','lon');
sst=ncread('sst.mnmean.nc','sst');
id1=find(lat>30&lat<60); %find function finds the index in lats where the value lies between 30 and 60
id2=find(lon>150&lon<240);
lat1=lat(id1); %lat1 stores those lat values from id1, in which the specific indices are saved
lon1=lon(id2);
sst1=nanmean(sst(id2,id1,:),3); % sst accepts the indices from id1 and id2 and mean takes the mean alone the third dimension
contourf(lon1,lat1,sst1','linecolor','none') %contour plot of the required plot.
You can delete the comments, which are written after %
  1 Comment
Amir Barkhordary
Amir Barkhordary on 7 Nov 2018
Thanks for the input. I have already seen your answer on a similar problem. However, I am not sure how to integrate your code to modify mine to create a mean plot.

Sign in to comment.

Categories

Find more on Time Series in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!