急求助:源程序提示错误.怎么调用函数,具体步骤?
function [positions,ranges]=...cp1002_create_network(N,area_side,G)
for i=1:N
positions(i,1)=rand*area_side;
positions(i,2)=rand*area_side;
j=1;
for j=1:(i-1)
ranges(i,j)=sqrt((positions(i,1)-...
positions(j,1))^2+(positions(i,2)-...
positions(j,2))^2;
while(ranges(i,j)==0)
X(i)=rand*50;
Y(i)=rand*50;
ranges(i,j)=sqrt((positions(i,1)-...
positions(j,1))^2+(positions(i,2)-...
positions(j,2))^2;
end
ranges(j,i)=ranges(i,j);
end
end
if G
scatter(positions(:,1),positions(:,2),'filled');
axis([0 area_side 0 area_side]);
xlable('X[m]');
ylable('Y[m]');
box on;
end
运行后提示错误
??? function [positions,ranges]=...
Error: Function definitions are not permitted at the prompt or in scripts.
麻烦高手指点一下,在matlab里怎么调用函数,具体步骤怎么做,十分感谢
[[it] 本帖最后由 snowfa 于 2008-11-11 08:07 编辑 [/it]]