이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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 개 추천
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
Amanda
2012년 8월 23일
Nope. That was a typo. I clear it out and still seeing the same error.
Matt Fig
2012년 8월 23일
I posted example code that doesn't rely on variable poofing. When I run it I get no errors. Did you try the above? If so and you still get an error, please post the entire error message and the entire contents of the callback function.
Amanda
2012년 8월 23일
Did you run it in GUIDE? It is a clean run in the script.
What is happening is Push button temp is interfering with another push button on guide. It is not clearing it out.
Matt Fig
2012년 8월 23일
No, I don't have your GUI, so I cannot run it. I assume your GUI has an axes object for plotting? What happens if you put this as the very first line of the callback:
figure
And do you still get an error when you used the alternate code I posted above? And if so, where is the whole error message?
Amanda
2012년 8월 23일
A figure plot windows appear outside the GUI.
Amanda
2012년 8월 23일
What is happening is that it appears and a click another push button for a graph and it plots that on top of the previous plot
Matt Fig
2012년 8월 23일
I see. If you only want one plot at a time, simply put this in before each time you plot:
cla
This clears the axes to accept another plot. So if you have many pushbuttons each plotting a different thing, the in each callback put cla in first. So now we know that the code does not error when plotting to another figure. Does it still error when plotting to the GUI axes?
Matt Fig
2012년 8월 23일
I made a simple GUI in guide. One with only an axes and a pushbutton. I then put the code I gave above in the callback for the pushbutton of the GUI. Here is what I got (no errors):

Amanda
2012년 8월 23일
Make another push button and plot a line plot. Then you will see the line plot plotted on top of the map.
Matt Fig
2012년 8월 23일
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
2012년 8월 23일
Thanks so mush for helping me. Let try this. I've been at this for 3 hours.
Amanda
2012년 8월 23일
That is it. Thanks so much!
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
