我想使用 Julia 计算点 (x(i), y(i)) 和 (x(j),y(j)) 之间的欧几里得距离,我使用以下代码
C = zeros(Float64,10,10)
x = [0.0, 20.0, 18.0, 30.0, 35.0, 33.0, 5.0, 5.0, 11.0, 2.0]
y = [0.0, 20.0, 10.0 ,12.0 ,0.0 ,25.0 ,27.0 ,10.0 ,0.0 ,15.0]
Required = [10.0, 6.0 ,8.0 ,11.0 ,9.0 ,7.0 ,15.0 ,7.0 ,9.0 ,12.0]
Present = [8.0, 13.0, 4.0, 8.0, 12.0, 2.0, 14.0, 11.0, 15.0, 7.0]
for i in 1:10
for j in 1:10
C[i,j] = 1.3*sqrt((x(i) - x(j))^2.0 + (y(i) - y(j))^2.0)
end
end
朱莉娅给了我以下结果
eLoadError: MethodError: `call` has no method matching call(::Array{Float64,1}, ::Int64)
Closest candidates are:
BoundsError()
BoundsError(!Matched::Any...)
DivideError()
...
while loading In[17], in expression starting on line 7
[inlined code] from In[17]:9
in anonymous at no file:0
谁能解决我的问题?谢谢!