Want to plot in my existing axes of GUI and then delete it.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Arun Sharma
el 28 de Feb. de 2016
Editada: Walter Roberson
el 29 de Feb. de 2016
Hello Everyone
I am trying to build a GUI that will display data coming from serial port. Posting whole code will create confusion, so i am posting the relevant part.
I created a axes in GUI and then update it, based on the data coming from the serial port it has to be updated again and then i have to delete some part.
Here is the code
set(handles.plot_vector(Angle),'XData',[x0,x]);
set(handles.plot_vector(Angle),'YData',[y0,y]);
% m = handles.plot_vector(Angle);
% set(m,'XData',[x0,0],'Color','Red','LineWidth',3);
% set(m,'YData',[y0,0],'Color','Red','LineWidth',3);
axes(handles.axes1)
m = plot([0,x0],[0,y0],'r','LineWidth',3);
drawnow
delete(m);
Actually i have to draw a straight line based on the Angle value coming from the Serial Port, so i used the following command and then have to delete this.
m = plot([0,x0],[0,y0],'r','LineWidth',3);
But the above line opens a new figure, but i have to do this thing on same axes.
I tried this
% m = handles.plot_vector(Angle);
% set(m,'XData',[x0,0],'Color','Red','LineWidth',3);
% set(m,'YData',[y0,0],'Color','Red','LineWidth',3);
This plots the line on axes but i don't know how to delete only this part.
Actually i am trying to display UltraSonic data in the form of radar in MATLAB GUI, So it will look like scanning, but stuck with this, hope someone helps me.
0 comentarios
Respuesta aceptada
Walter Roberson
el 28 de Feb. de 2016
m = plot(handles.axes1, [0,x0], [0,y0], 'r', 'LineWidth', 3);
drawnow
delete(m);
Since you are doing this repeatedly it would be better to create a line at the beginning and update it as you go along.
m = plot(handles.axes1, nan, nan, 'r', 'LineWidth', 3);
while true
...
set(m, 'XData', [0 x0], 'YData', [0 y0]);
drawnow();
...
end
delete(m); %when we are done with drawing lines
1 comentario
Arun Sharma
el 29 de Feb. de 2016
Editada: Walter Roberson
el 29 de Feb. de 2016
Más respuestas (0)
Ver también
Categorías
Más información sobre Graphics Performance 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!