現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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
採用された回答
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
