Problem with a GUI file
3 次查看(过去 30 天)
显示 更早的评论
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)
0 个评论
采纳的回答
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!