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