Unable to use load coast and geoshow as it was in the R2017a version.

조회 수: 15 (최근 30일)
Joydeb Saha
Joydeb Saha 2024년 3월 7일
답변: Austin M. Weber 2024년 3월 7일
clear
clc
ncFilePath = 'E:\ERA5\U\U_Clim_1987_2016\U_06\U_06.nc';
ncid = netcdf.open(ncFilePath, 'NOWRITE');
lat = netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'latitude'));
lon = netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'longitude'));
time = netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'time'));
u10 = netcdf.getVar(ncid, netcdf.inqVarID(ncid, 'u10'));
netcdf.close(ncid);
u10_mean = mean(u10, 3);
lat_limit = [0 40];
lon_limit = [60 120];
lat_indices = find(lat >= lat_limit(1) & lat <= lat_limit(2));
lon_indices = find(lon >= lon_limit(1) & lon <= lon_limit(2));
lon_subset = lon(lon_indices);
lat_subset = lat(lat_indices);
[lon_grid, lat_grid] = meshgrid(lon_subset, lat_subset);
figure;
contourf(lon_subset, lat_subset, u10_mean(lat_indices, lon_indices)', 20, 'LineColor', 'none');
colorbar;
title('Spatial Map of Mean u10 (Region of Interest)');
xlabel('Longitude');
ylabel('Latitude');
The problem is I want to create a spatial map in the given lat lon grids. I am unable to use the load coast and geoshow here in 2023b version. I have used coastline.mat function, still there are some problems, how can I use load coast and geoshow here in the code so that I can have a spatial map only in the given lat lon grid

답변 (1개)

Austin M. Weber
Austin M. Weber 2024년 3월 7일
The command is not load coast but rather:
load coastlines
Here is an example of how you can use it:
load coastlines
figure
ax=axesm('mollweid','maplonlimit', [60 120],'maplatlimit',[0 40]);
%contourfm(lon_subset, lat_subset, u10_mean(lat_indices, lon_indices)')
colorbar
hold on
plotm(coastlat,coastlon,'k')
hold off
tightmap
framem
gridm
Just un-comment the line containing contourfm and see if that works.

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by