Error using gcm?

9 次查看(过去 30 天)
nuvolet
nuvolet 2018-10-15
回答: Chad Greene 2018-10-17
Hi all,
I am running a code which makes a global plot using plotm before I loaded coast.mat and defines the axesm as:
axesm('MapProjection','eqdcylin','Frame','on','Grid','on',...
'MapLatLimit',[-90 90],'MapLonLimit',lonlim, ...
'MeridianLabel','on','ParallelLabel','on','MLabelParallel','south')
The code worked perfectly but now is not getting this message:
Error using gcm (line 25)
Not a map axes.
Error in nextmap (line 24)
gcm; % Will error if gca is not a valid map axes
Error in nextmap (line 43)
nextmap
Error in plotm (line 59)
nextmap(varargin)
Error in plot_data_CLCS_5x5 (line 44)
plotm(coast.lat,coast.long);hold on; tightmap;
Anybody had the same problem and has been able to solve. Thanks in advance

回答(1 个)

Chad Greene
Chad Greene 2018-10-17
It looks like another plot was initialized or clicked on after calling axesm, because this should work just fine:
figure
lonlim = [-60 120];
axesm('MapProjection','eqdcylin','Frame','on','Grid','on',...
'MapLatLimit',[-90 90],'MapLonLimit',lonlim, ...
'MeridianLabel','on','ParallelLabel','on','MLabelParallel','south')
coast = load('coast');
plotm(coast.lat,coast.long)
whereas this will produce the error message you're getting:
figure
lonlim = [-60 120];
axesm('MapProjection','eqdcylin','Frame','on','Grid','on',...
'MapLatLimit',[-90 90],'MapLonLimit',lonlim, ...
'MeridianLabel','on','ParallelLabel','on','MLabelParallel','south')
coast = load('coast');
figure % <-THIS WILL SCREW THINGS UP
plotm(coast.lat,coast.long)

Community Treasure Hunt

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

Start Hunting!

Translated by