Problem with a GUI file
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Image Analyst
le 29 Mai 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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!