Using interp2 with pcolor and loop.

조회 수: 2 (최근 30일)
Ross O'Connell
Ross O'Connell 2019년 7월 24일
답변: SaiDileep Kola 2019년 7월 31일
Hi all.
I have the script created below for mapping wind speeds off the Irish coast. I am trying to use interp2 to use a finer grid but it will not work for me so I must be putting it in the wrong place. Does anyone have any suggestions on how and where in the script interp2 should be integrated?
Thank you.
%%%% SCRIPT %%%%%
long = ncread(ncfile,'longitude');
lat = ncread(ncfile,'latitude');
% create a cartesian grid in 2-D space using longitude and latitude
[X,Y] = meshgrid(long,lat);
[X_ERA5,Y_ERA5] = meshgrid(lon_ERA5,lat_ERA5);
for i = 1:72
for j = 1:88
lat_pixel = Y(i,j);
lon_pixel = X(i,j)+360;
diffLat = abs(lat_ERA5-lat_pixel);
diffLon = abs(lon_ERA5-lon_pixel);
lat_index = find(diffLat==min(diffLat));
lon_index = find(diffLon==min(diffLon));
WinPwrMap (i,j) = wind_speed (lat_index,lon_index);
end
end
figure (1)
pcolor(X,Y,WinPwrMap);
shading interp;
sgtitle('Wind Power Resource off Irish Coast')
colorbar
xlabel ('Longitude')
ylabel ('Latitude')
colormap('jet')
c = colorbar;
c.Label.String = 'Wind Speed (m/s)';
  댓글 수: 1
Jan
Jan 2019년 7월 24일
편집: Jan 2019년 7월 24일
"it will not work for me" - please explain any details of the occurring problems. Post the code you have tried, and the corresponding error message.

댓글을 달려면 로그인하십시오.

답변 (1개)

SaiDileep Kola
SaiDileep Kola 2019년 7월 31일
I see that you have set of coordinates (X,Y) and (X_ERA5,Y_ERA5), you can use interp2 to get 2-D gridded
Vq = interp2(X,Y,V,Xq,Yq)
You may refer to the MATLAB documentation for interp2 and pcolor

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by