1. 效果(动图)
2. 代码
%Brownian motion 布朗运动
clc,clear,close all; %清除命令,清空工作区,关闭所有窗口
n=20;
s=0.02;
x = rand(n,1)-0.5;
y = rand(n,1)-0.5;
h = plot(x,y,'.', 'MarkerSize',18);
axis([-1 1 -1 1])
axis square
grid off
% set(h,'EraseMode','xor','MarkerSize',18)
grid on;
title('Press Ctl-C to stop');
while true
x = x + s*randn(n,1);
y = y + s*randn(n,1);
set(h,'XData',x,'YData',y)
drawnow
end
来源:CSDN
作者:COCO56
链接:https://blog.csdn.net/COCO56/article/details/103463144