Want to plot in my existing axes of GUI and then delete it.
1 view (last 30 days)
Show older comments
Arun Sharma
on 28 Feb 2016
Edited: Walter Roberson
on 29 Feb 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 Comments
Accepted Answer
Walter Roberson
on 28 Feb 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 Comment
More Answers (0)
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!