I would appreciate any help on this. Problem is defining 'newsst', i have tried with also with a loop (commented) but theres something dimension wise i dont get..
Have attached the data and hope the code is descriptive enough.
% load and store netcdf file variables in separate matrices
ncdisp('sst_2015.nc') sst = ncread('sst_2015.nc','sea_surface_temperature');time = ncread('sst_2015.nc','time');lat = ncread('sst_2015.nc','lat'); %latitude
lon = ncread('sst_2015.nc','lon'); %longitude
%exclude potential values from outside the defined box of coordinates below
% Note: use of '&&' instead of '&' below creates an error: 'Operands to the || and &&
% operators must be convertible to logical scalar values'. Works with '&',
% not sure if correct.
newlat = find(lat>50&lat<60); newlon = find(lon>-3&lon<11);%change to desired degree of resolution for latitude and longitude
ds_lat=0.1000; ds_lon = 0.1666; lati=50:ds_lat:60; loni=-3:ds_lon:11; [Loni,Lati] = meshgrid(loni,lati) ;newsst = sst(newlat,newlon,time);% newsst = zeros (i,j,k); i,j,k loop base on dimensions of sst
% for i=1:140
% for j=1:101
% for k=1:355
%
% newsst = sst(newlat(i),newlon(j),time(k));
% % end
%
% end
% end
%interpolate and put everything in a new grid. we will now have values on same
%lat and lon points defined by Loni and Lati
NEWSST = griddata (Loni,Lati,newlat,newlon,newsst);
Best Answer