How can I delete a plotted line in an axes GUI?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to create a GUI that allows the user to add forces in polar or rectangular format and displays these forces in a graph, calculates the resultant force for every force that has been entered and then displays the resultant force in the graph. I am having difficulty when I add a new force, the previous resultants remain plotted when I would like the resultant to be replaced as it is recalculated every time a new force is added.
axes(handles.graph);
plot([0 x(n)],[0 y(n)],'r--'); % plots each entered force
grid on;
hold on;
axis([-10 10 -10 10]);
final = plot([0 x_res],[0 y_res],'b-'); % plots resultant
legend(final,'Resultant');
0 Commenti
Risposte (1)
Jan
il 3 Apr 2017
Store the handle of the line and delete formerly existing lines:
delete(handles.final);
handles.final = plot([0 x_res],[0 y_res],'b-');
guidata(hObject, handles);
Set handles.final to [] in the OpeningFcn.
Vedere anche
Categorie
Scopri di più su Graphics Objects in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!