matlab产生N个随机点。。每两点之间的距离必须大于一个固定值M。。。该怎么写程序......
clc;clear;x=[];x1=unifrnd(0,5000);y1=unifrnd(0,5000);x(1,:)=[x1,y1];OF=1;CF=1;while(O...
clc;
clear;
x=[];
x1=unifrnd(0,5000);
y1=unifrnd(0,5000);
x(1,:)=[x1,y1];
OF=1;
CF=1;
while(OF<=10)
x11=unifrnd(0,5000);
y11=unifrnd(0,5000);
for i=1:size(x,1)
distance=sqrt((x11-x(i,1))^2+(y11-x(i,2)^2));
if distance<100
CF=2;
end
end
if CF==1;
x(size(x,1)+1,1)=x11;
x(size(x,1),2)=y11;
OF=OF+1;
end
CF=1;
end 展开
clear;
x=[];
x1=unifrnd(0,5000);
y1=unifrnd(0,5000);
x(1,:)=[x1,y1];
OF=1;
CF=1;
while(OF<=10)
x11=unifrnd(0,5000);
y11=unifrnd(0,5000);
for i=1:size(x,1)
distance=sqrt((x11-x(i,1))^2+(y11-x(i,2)^2));
if distance<100
CF=2;
end
end
if CF==1;
x(size(x,1)+1,1)=x11;
x(size(x,1),2)=y11;
OF=OF+1;
end
CF=1;
end 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |