Problem with a GUI file

1 回表示 (過去 30 日間)
aurc89
aurc89 2014 年 5 月 29 日
コメント済み: aurc89 2014 年 5 月 29 日
Hi! It's the first time I'm going to use 'guide' on Matlab to create GUI file and I don't understand something. My question is: if I want to plot two curves separately, what shall I do? As you can see in the figure i created two push buttons ('plot a line' and 'plot a parabola') and two axes ('axes1' and 'axes2'); the first push button plots a line, while the second one plots a parabola.
The problem is that both graphs are plotted on the same axes (axes2) when I press both buttons, while I'd like to plot the line on axes1 and the parabola on axes2. How can I do ? The code is the following:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=[0,1,2,3,4,5,6];
b=a;
plot(a,b)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)a=[0,1,2,3,4,5,6];
c=[0,1,2,3,4,5,6];
d=c.^2;
plot(c,d)

採用された回答

Image Analyst
Image Analyst 2014 年 5 月 29 日
Call the axes you want to use before you call plot:
axes(handles.axes1); % Set current axes to axes1.
plot(.....
or use axes2, whichever one you want to plot into.
  1 件のコメント
aurc89
aurc89 2014 年 5 月 29 日
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by