- 积分
- 46
- 注册时间
- 2007-4-28
- 仿真币
-
- 最后登录
- 1970-1-1
|
看到有人用mathematica模拟,我也写了一个Matlab的模拟程序:
-
- clear;clc;close all
- rectangle('Position',[1,1,1,1],...
- 'Curvature',[0,0],...
- 'LineWidth',2,'LineStyle','-')
- axis([0.9 2.1 0.9 2.1])
- daspect([1,1,1])
- x=[1 1 2 2];
- y=[1 2 2 1];
- n=10000;
- axis off
- hold on
- h=zeros(length(x),1);
- for i=1:4
- h(i)=plot(x(i),y(i),'r.','markersize',10,'erasemode','none');
- end
- title('\copyright:qibbxxt')
- t=0.001;
- dirx=[0,t,0,-t];
- diry=[t,0,-t,0];
- for i=1:n
- x=x+t*dirx*i/10;
- y=y+t*diry*i/10;
- dirx=diff([x,x(1)]);
- diry=diff([y,y(1)]);
- if dist([x(1),y(1)],[x(2);y(2)])<15*t
- break
- end
- arrayfun(@set,h,repmat({'xdata'},4,1),num2cell(x'),repmat({'ydata'},4,1),num2cell(y'));
- pause(0.01);
- end
复制代码
mathematica程序见:http://forum.simwe.com/thread-949737-1-1.html |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
×
评分
-
1
查看全部评分
-
|