m = 100;
X = zeros(m,m);
V = zeros(m,m);
n=randint(1,1,[15,25]);
data=randperm(95);%1到100随机排列
y=data(1:n);%取前n个整数
i=sort(y);%将y从小到大排列
X(i,1)=i;
V(i,1)=randint(1,n,[1,5]);%随机产生速度
for t=1:100
rand
if rand>=0.6
X(1,t)=0;
V(1,t)=0;
X(100,t)=1;
V(100,t)=randint(1,1,[1,5]);
else X(1,t)=1;
V(1,t)=randint(1,1,[1,5]);
X(100,t)=0;
V(100,t)=0;
end
for i=1:94
% 轨迹变化规则
if X(i,t)>0
if X(i+1,t)>0
X(i,t+1)=1;
V(i,t+1)=0;
elseif X(i+2,t)>0
X(i+1,t+1)=1;
V(i+1,t+1)=1;
elseif X(i+3,t)>0
X(i+2,t+1)=1;
V(i+2,t+1)=2;
elseif X(i+4,t)>0
X(i+3,t+1)=1;
V(i+3,t+1)=3;
elseif X(i+5,t)>0
X(i+4,t+1)=1;
V(i+4,t+1)=4;
elseif X(i+6,t)>0
rand
if rand>=0.7
X(i+5,t+1)=1;
V(i+5,t+1)=5;
else X(i+4,t+1)=1;
V(i+4,t+1)=4;
end
else rand
if rand>=0.7
X(i+5,t+1)=1;
V(i+5,t+1)=5;
else X(i+4,t+1)=1;
V(i+4,t+1)=4;
end
end
end
end
%绘制图形
[i,j] = find(V);
figure(gcf);
plothandle = plot(i,j,'.', ...
'Color','blue', ...
'MarkerSize',12);
axis([0 m 0 m]);
pause(0.2)
end
以上为源程序 我想在坐标处显示V的值 不知道怎么该啊,只好求助各位大侠了了。。。。
在线等。。明天交程序,拜托了
[本帖最后由 mooni 于 2009-6-14 11:18 编辑]