在MATLAB中改变点沿图形移动的速度
我在其他问题中使用了@Amro提供的代码:在MATLAB中改变点沿图形移动的速度,matlab,graph,velocity,marker,Matlab,Graph,Velocity,Marker,我在其他问题中使用了@Amro提供的代码: %# control animation speed DELAY = 0.01; numPoints = 600; %# create data x = linspace(0,10,numPoints); y = log(x); %# plot graph figure('DoubleBuffer','on') %# no flickering plot(x,y, 'LineWidth',2), grid on x
%# control animation speed
DELAY = 0.01;
numPoints = 600;
%# create data
x = linspace(0,10,numPoints);
y = log(x);
%# plot graph
figure('DoubleBuffer','on') %# no flickering
plot(x,y, 'LineWidth',2), grid on
xlabel('x'), ylabel('y'), title('y = log(x)')
%# create moving point + coords text
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');
%# infinite loop
i = 1; %# index
while true
%# update point & text
set(hLine, 'XData',x(i), 'YData',y(i))
set(hTxt, 'Position',[x(i) y(i)], ...
'String',sprintf('(%.3f,%.3f)',[x(i) y(i)]))
drawnow %# force refresh
%#pause(DELAY) %# slow down animation
i = rem(i+1,numPoints)+1; %# circular increment
if ~ishandle(hLine), break; end %# in case you close the figure
end
但我需要改变标记的速度。我尝试过改变延迟的值,但没有成功。关键是我不能更改numPoints(函数的大小),所以我不知道该怎么做。
有什么想法吗
谢谢 只需取消对无限循环中的暂停(延迟)的注释即可。将延迟更改为合适的值只需取消对无限循环中的暂停(延迟)的注释。将延迟更改为合适的值