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!