在代码运行时显示简单的随机游走结果 [英] Showing simple random walk result when the code is running

查看:75
本文介绍了在代码运行时显示简单的随机游走结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为2个N个简单的随机步行者编写了一个代码.我不想在所有步骤中保存粒子的位置,而是想在代码运行时显示影片中粒子的位置.这样,我不需要在所有步骤中都保存有关粒子位置的信息.

I wrote a code for N simple random walkers in 2D. I don't want to save particles position in all steps, instead, I want to show the position of particles in a movie when the code is running. In this way, I don't need to save information about positions of particles in all steps.

有人可以帮忙吗?任何人都可以编写代码以这种方式显示粒子的运动吗?

Could anyone help? Could anyone write a code to show the motion of particles in this way?

推荐答案

类似的东西:

figure()
hold on
for ii=1:long_walk

    [x2,y2]=computeLocationOfNextStep(x1,y1);

    plot([x1,x2],[y1,y2],'b');
    plot(x2,y2,'rx');
    drawnow
    pause(0.05) %or longer, I am not your boss

    x1=x2;
    y1=y2;

end

这篇关于在代码运行时显示简单的随机游走结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆