# Help with convert error from Array{Float64, 2} to Float64

**URL:** https://discourse.julialang.org/t/help-with-convert-error-from-array-float64-2-to-float64/47792
**Category:** General Usage
**Created:** [October 5, 2020, 12:30pm UTC](https://discourse.julialang.org/t/help-with-convert-error-from-array-float64-2-to-float64/47792 "2020-10-05T12:30:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jayanth\_jayasimha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jayanth_jayasimha/32/18432_2.png) [@jayanth\_jayasimha](https://discourse.julialang.org/u/jayanth_jayasimha)
#### Post date: [October 5, 2020, 12:30pm UTC](https://discourse.julialang.org/t/help-with-convert-error-from-array-float64-2-to-float64/47792/1 "2020-10-05T12:30:20Z")

</div>

Hi  
How do you clear this error please do help me at the earliest.

gmsh.initialize(ARGS)  
gmsh.option.setNumber(“General.Terminal”, 1)  
gmsh.model.add(“Jayanth model”)  
using LinearAlgebra

gmsh.initialize(ARGS)  
gmsh.option.setNumber(“General.Terminal”, 1)  
gmsh.model.add(“Jayanth model”)

#Diemensions of the RVE\_Box  
x1 = 0.0; y1 = 0.0; z1 = 0.0;  
l1 = 10.0; l2 = 10.0; l3 = 10.0;

gr = 1 # Graphite radius  
fr = 1.1 # Ferrite radius  
# x[v] = x[i];  
toler = 2 \* fr # tolerance value assumed  
n = 5 # Number of nodules  
g = zeros(n,1)  
f = zeros(n,1)  
b = gmsh.model.occ.addBox(x1, y1, z1, l1, l2, l3)

```
  gmsh.model.occ.synchronize()
  box = gmsh.model.addPhysicalGroup(3, [b], 1000)
  gmsh.model.setPhysicalName(3, box, "Box")
  gmsh.model.occ.synchronize()

  p = 1
  x = zeros(n,1);
  y = zeros(n,1);
  z = zeros(n,1);

```

for i = 1:n  
global p,x,y,z,d,v  
# global b  
x[i] = norm(l1_rand(1));  
y[i] = norm(l2_rand(1));  
z[i] = norm(l3\*rand(1));

if i == 1  
d = zeros(n,n)  
x\_new = zeros(n,1);  
y\_new = zeros(n,1);  
z\_new = zeros(n,1);

```
    v = zeros(n,n)
    #q = zeros(n,n)

```

end

```
      for j = 1:n

        d[i,j] = sqrt((x[i]-x[j])^2+(y[i]-y[j])^2+(z[i]-z[j])^2);
        if d[i,j] > toler
          #q[i,j] = i
          v[i,j] = j
        else
          #q[i,j] = 0
          v[i,j] = 0

        end
      end

    #y[v] = y[i];
  # z[v] = z[i];
  # i[v] = i;
    #j[v] = j;

```

g[i] = gmsh.model.occ.addSphere(x, y, z, gr, (2_i-1)+1+p, -π/2, π/2, 2_π)  
#println(“Graphite nodule number “,i,” is created.”)  
gmsh.model.occ.synchronize()

f[i] = gmsh.model.occ.addSphere(x, y, z, fr, 2_i+1+p, -π/2, π/2, 2_π)  
#println(“Ferrite number “,i,” is created.”)  
gmsh.model.occ.synchronize()  
end

LoadError: MethodError: Cannot `convert` an object of type Array{Float64,2} to an object of type Float64  
Closest candidates are:  
convert(::Type{T}, ::T) where T\<:Number at number.jl:6  
convert(::Type{T}, ::Number) where T\<:Number at number.jl:7  
convert(::Type{T}, ::Base.TwicePrecision) where T\<:Number at twiceprecision.jl:250

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [October 5, 2020, 2:59pm UTC](https://discourse.julialang.org/t/help-with-convert-error-from-array-float64-2-to-float64/47792/2 "2020-10-05T14:59:17Z")

</div>

Welcome @jayanth_jayasimha — I’ve moved your post into a new thread. While it has roughly the same error message, the cause is different than in the thread you posted.

Check out the [Please read: make it easier to help you - #81](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757/81) guide to make it a bit easier for folks to help you.

In this case, it looks like you’re wholesale converting a piece of MATLAB code into Julia. I highly recommend going piecemeal, a little at a time. This will help you narrow down _where_ the issue is, which is 90% of understanding _what_ the issue is.

In short, the error message is telling you that you’re trying to use an array like a single floating point number — something that MATLAB does (since everything is an array) but Julia is a bit pickier about.
