Error using gcm?

12 ビュー (過去 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