How can I get new plot on the same axes when the user put the new input and presses push button?

Hello, I am developing a gui in which I have given the push button and some inputs. After pressing push button plot will generate on the axes of the gui but the problem is occurring in the next step when I will again put the new value in the input then the plot is being overwrite by the old plot. How can I remove the old plot after putting the new inputs?
Thanks

4 Comments

in my opinion your question is very confusing, maybe add the code and explain more precisely what should happen if this or that
function pushbutton_Callback(hObject, eventdata, handles)
x=str2num(get(handles.x,'String'));
y=Str2num(get(handles.y,'String'));
m=str2num(get(handles.m,'String'));
n=Str2num(get(handles.n,'String'));
plot(handles.plotAxes,x,y);
hold(handles.plotAxes,'on' );
plot(handles.plotAxes,m,n);
hold (handles.plotAxes,'on');
This is my commands and I have created four inputboxes x,y,m,n. when I am giving input I will get plot after pressing pushbutton i.e plot my main problem is that when I am giving new input to anyone text boxe then there should be new plot but it is getting overwrite and showing four plots simultaneously. please suggest me to get out of this problem. Thanks.
If you want to clear all existing plots when you next press the button you need to put
hold( handles.plotAxes, 'off' )
at the start. Or
cla( handles.plotAxes )

Sign in to comment.

 Accepted Answer

if you use
hold on
every next (new) plot will added to the old plot, so both/ all plots will be shown.
to deactivate adding plots use hold off (documentation of hold)
hold off % default option, only need to use if you used hold on before
so that every new plot automatically deletes the old one

More Answers (0)

Categories

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!