InexactError()

Hello! I need some help with my code. I’m getting this following error when i try to run my code:

ERROR: LoadError: InexactError()
Stacktrace:
 [1] convert at .\complex.jl:31 [inlined]
 [2] setindex!(::Array{Float64,2}, ::Complex{Float64}, ::Int64, ::Int64) at .\array.jl:579
 [3] macro expansion at C:\Users\Muril\AppData\Local\atom\app-1.28.0\Arquivos Feitos\dsadasdsa.jl:42
 [inlined]
 [4] anonymous at .\<missing>:?
 [5] include_string(::String, ::String) at .\loading.jl:522
 [6] include_string(::Module, ::String, ::String) at C:\Users\Muril\.julia\v0.6\Compat\src\Compat.jl
:88
 [7] (::LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.La
stMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.Atom.##112#116{String,String})
() at C:\Users\Muril\.julia\v0.6\Atom\src\eval.jl:109
 [8] withpath(::LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.Las
tMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.Atom.##112#116{String,
String}, ::String) at C:\Users\Muril\.julia\v0.6\CodeTools\src\utils.jl:30
 [9] withpath(::Function, ::String) at C:\Users\Muril\.julia\v0.6\Atom\src\eval.jl:38
 [10] hideprompt(::LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.
LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.Atom.##111#115{Stri
ng,String}) at C:\Users\Muril\.julia\v0.6\Atom\src\repl.jl:67
 [11] macro expansion at C:\Users\Muril\.julia\v0.6\Atom\src\eval.jl:106 [inlined]
 [12] (::LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.L
astMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.Atom.##110#114{Dict{String,An
y}})() at .\task.jl:80
while loading C:\Users\Muril\AppData\Local\atom\app-1.28.0\Arquivos Feitos\dsadasdsa.jl, in expressi
on starting on line 40
ERROR: LoadError: InexactError()
Stacktrace:
 [1] convert at .\complex.jl:31 [inlined]
 [2] setindex!(::Array{Float64,2}, ::Complex{Float64}, ::Int64, ::Int64) at .\array.jl:579
 [3] macro expansion at C:\Users\Muril\AppData\Local\atom\app-1.28.0\Arquivos Feitos\dsadasdsa.jl:42
 [inlined]
 [4] anonymous at .\<missing>:?
 [5] include_string(::String, ::String) at .\loading.jl:522
 [6] include_string(::Module, ::String, ::String) at C:\Users\Muril\.julia\v0.6\Compat\src\Compat.jl
:88
 [7] (::LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.La
stMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.Atom.##112#116{String
,String})() at C:\Users\Muril\.julia\v0.6\Atom\src\eval.jl:109
 [8] withpath(::LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.Las
tMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.Atom.##112#11
6{String,String}, ::String) at C:\Users\Muril\.julia\v0.6\CodeTools\src\utils.jl:30
 [9] withpath(::Function, ::String) at C:\Users\Muril\.julia\v0.6\Atom\src\eval.jl:38
 [10] hideprompt(::LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.
LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.Atom.##111
#115{String,String}) at C:\Users\Muril\.julia\v0.6\Atom\src\repl.jl:67
 [11] macro expansion at C:\Users\Muril\.julia\v0.6\Atom\src\eval.jl:106 [inlined]
 [12] (::LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.L
astMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.LastMain.Atom.##110#114{Dict{
String,Any}})() at .\task.jl:80
while loading C:\Users\Muril\AppData\Local\atom\app-1.28.0\Arquivos Feitos\dsadasdsa.jl, in expressi
on starting on line 40

And my code is, basically, this:

R = (r.*Lcomp)';
X = (x.*Lcomp)';

y1 = zeros(Nt,hmax)

for h = 3:2:hmax
    for i = 1:Nt
        y1[i,h] = 1/(R[i]+im*h*X[i]);
    end
end

Here we got:

Nt = 17

hmax = 25

R = [0.0105 0.0602 0.0214 0.0416 0.0110 0.0925 0.0100 0.1223 0.3612 0.1202 0.3497 0.2038 0.9523 0.6557 0.3497 0.5736 0.2011]

X = [0.0721 1.3021 0.0598 0.1161 0.0307 0.2584 0.0281 0.1507 0.2710 0.1557 0.4527 0.2639 1.2329 0.8490 0.4527 0.7069 0.2478]

You need y1 = zeros(Complex128, Nt,hmax). This makes an array of complex numbers, which can then indeed by filled with complex numbers.

1 Like

Yes, that worked. Thanks for the info!