Remove underlying graph and eliminate flickering.

11 次查看(过去 30 天)
Hello, I have a code that shows a dot moving up and down on a picture. However, the dot is moving on an underlying sin curve so when I run the program, the whole thing flickers. I want to remove the flickering and only show the dot moving on the picture without seeing the sine curve. How would I do this?
x = 0:.01:50; %linspace of x
y = sin(x); %wave equation
px = 10; %initial x plot
py = 0; %initial y plot
img =imread('AvgBscan.tiff'); %read in image
for i=1:630 %loop
imshow(img);
set(gcf,'DoubleBuffer', 'off');
h = patch([0 1 0 1], [0 1 1 0], 'r');
hold on
figure(100);%so code will replot over the previous figure, and not make a new one.
hold off
py = y(i)
plot(x,y, px, py,'o'); %circle point
pause(0.05); %speed of moving point

回答(1 个)

Steven Lord
Steven Lord 2020-8-15
Don't keep plotting and deleting graphics objects. I recommend the "Update the properties of a graphics object and display the updates on the screen" approach described on this documentation page. The first two Related Topics on that page demonstrate two techniques by which you can do that.
  1 个评论
SS
SS 2020-8-20
I read through the related topics but it didn't really cover how to move the point off the line. I do not want the sine wave to be shown under the picture, I just want to see the point moving up and down. How would I do this?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 General Applications 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by