Error using gcm?

11 views (last 30 days)
nuvolet
nuvolet on 15 Oct 2018
Answered: Chad Greene on 17 Oct 2018
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

Answers (1)

Chad Greene
Chad Greene on 17 Oct 2018
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)

Products

Community Treasure Hunt

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

Start Hunting!