Here is a variant of @Jacob . Instead of redrawing everything in each frame ( clf), we simply update the location of the point:
%
DELAY = 0.01;
numPoints = 600;
%
x = linspace(0,10,numPoints);
y = log(x);
%
figure('DoubleBuffer','on') %
plot(x,y, 'LineWidth',2), grid on
xlabel('x'), ylabel('y'), title('y = log(x)')
%
hLine = line('XData',x(1), 'YData',y(1), 'Color','r', ...
'Marker','o', 'MarkerSize',6, 'LineWidth',2);
hTxt = text(x(1), y(1), sprintf('(%.3f,%.3f)',x(1),y(1)), ...
'Color',[0.2 0.2 0.2], 'FontSize',8, ...
'HorizontalAlignment','left', 'VerticalAlignment','top');
%
i = 1; %
while true
%
set(hLine, 'XData',x(i), 'YData',y(i))
set(hTxt, 'Position',[x(i) y(i)], ...
'String',sprintf('(%.3f,%.3f)',[x(i) y(i)]))
drawnow %
%
i = rem(i+1,numPoints)+1; %
if ~ishandle(hLine), break; end %
end
