Problem with a GUI file
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
aurc89
el 29 de Mayo de 2014
Comentada: aurc89
el 29 de Mayo de 2014
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 comentarios
Respuesta aceptada
Image Analyst
el 29 de Mayo de 2014
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!