GUI GUIDE Error with Map

Asked by Amanda on 23 Aug 2012
Latest activity Commented on by Amanda on 23 Aug 2012

I'm trying to insert a map into the GUI GUIDE and I'm getting the error:

"Error while evaluating uicontrol Callback"

The map does work when I run it standalone in the command

window but when I push the button in GUIDE, it appears then gets

distorted, and then

I get an error.

Here is my code:

 function temp_button_Callback(hObject,eventdata,handles)
 lat = [80 45 52; 45 46 34]
 long = [123 132 123; 120 122 119]
 temp = [67 68 69; 71 72 73]
 axesm('mercator','MapLatLimit',[-50 90],'MapLonLimit',[0 250])
 framem on; gridm on;
 load coast;
 mlabel on;
 plabel on;
 plotm(lat,long,'k')
 contourfm(long,lat,temp)

Thanks,

Amanda

0 Comments

Amanda

Tags

Products

No products are associated with this question.

1 Answer

Answer by Matt Fig on 23 Aug 2012
Edited by Matt Fig on 23 Aug 2012
Accepted answer

You clear long and lat, then immediately try to use them. This is your error. You also rely on Poofing variables into your workspace... This is a very bad habit you should break while the debugging is easy!

lat = [80 45 52; 45 46 34];
long = [123 132 123; 120 122 119];
temp = [67 68 69; 71 72 73];
axesm('mercator','MapLatLimit',[-50 90],'MapLonLimit',[0 250])
framem on; gridm on;
X = load('coast');  % No variable Poofing!!
mlabel on;
plabel on;
plotm(X.lat,X.long,'k')
contourfm(long,lat,temp)

13 Comments

Matt Fig on 23 Aug 2012

Not if I put cla in the callback for the line-plotting-pushbutton. Here is the callback for the new pushbutton:

cla
plot(1:10)

No line on the map. Did you want a line on the map?

Amanda on 23 Aug 2012

Thanks so mush for helping me. Let try this. I've been at this for 3 hours.

Amanda on 23 Aug 2012

That is it. Thanks so much!

Matt Fig

Contact us