plotting two curve in one axes

1 visualización (últimos 30 días)
Samer Husam
Samer Husam el 18 de Sept. de 2012
Hi all; I have to plot two functions in same axes these functions in two different pushbutton functions, the code so far is as follow:
- function pushbutton1_Callback(hObject, eventdata, handles)
x = [31 32 32 33 34 35 35 37 37]; % data 1
y = [0 3 11 29 53 80 98 126 150]; % maximum power
plot(handles.axes,x,y)
- function pushbutton2_Callback(hObject, eventdata, handles)
x = [31 32 32 33 34 35 35 37 37]; % data 1
y1=y*0.7; % actual power
plot(handles.axes,x,y1)
the problem that i am facing is when plotting the second function the first is disappear. how to overcome this issue ?? please help and advice.
Sam

Respuesta aceptada

Samer Husam
Samer Husam el 21 de Sept. de 2012
by using (handles.axes) so need to hold on this axes, if using hold on only its not working it will work only with plot(x,y) not with plot(handles.axes,x,y) the code should be as follow:
- function pushbutton1_Callback(hObject, eventdata, handles)
x = [31 32 32 33 34 35 35 37 37]; % data 1
y = [0 3 11 29 53 80 98 126 150]; % maximum power
plot(handles.axes,x,y)
- function pushbutton2_Callback(hObject, eventdata, handles)
x = [31 32 32 33 34 35 35 37 37]; % data 1
y1=y*0.7; % actual power
hold(handles.axes,'on')
plot(handles.axes,x,y1)

Más respuestas (2)

Azzi Abdelmalek
Azzi Abdelmalek el 18 de Sept. de 2012
hold on;
plot(handles.axes,x,y1)
  10 comentarios
Samer Husam
Samer Husam el 20 de Sept. de 2012
I just remove it cause its not the main of what i am asking for. when I am using the (hold on) the first function is disappear, so I wounder how to overcome this issue ?
Azzi Abdelmalek
Azzi Abdelmalek el 20 de Sept. de 2012
to find the problem, it's usefull to read the full code, at least of functions that are involved. Because there is no problem with
hold on;
plot(handles.axes,x,y1)
I did it and it works

Iniciar sesión para comentar.


Jürgen
Jürgen el 18 de Sept. de 2012
use the hold function
hold on for example will help
regardsJ

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by