Hello,
I am newbie in julia, writing my first code! So, I apologize in advance if my question is a bit stupid.
What I’m doing:
include("S.jl")
using FFTW
L = 5 # Interval length
N = 10 # Number of spatial partitions
h = (2*L)/N # Space step
x = -L:h:L # Space discretized, length: N+1
u = Array{Float64,2}(undef,n,N+1) # Pre-allocate matrix u
u[1,:].= 0 # Initial condition U(x,0) = 0
...
inputS = real(fft(u[1,:])) # Apply Fast Fourier Transform
...
S.(inputS,N)
And S is a very simple script:
function S(x::Array{Float64,1},N::Int64)
s = Array{Float64,1}(undef,N+1)
for i = 1:N+1
if x[i] > 0
s[i] = 1
else
s[i] = 0
end
end
return s
end
When I try to run the instruction S.(inputS,N) I get the following error massage:
MethodError: no method matching S(::Float64, ::Int64)
To debug, I ran the following code in the REPL:
s = Array{Float64,1}(undef,N+1)
for i = 1:N+1
if inputS[i] > 0
s[i] = 1
else
s[i] = 0
end
end
It ran without any problems and did the expected.
The last test I did was to initialize the variable N in the S.jl script, then I got a different error:
ERROR: ArgumentError: invalid index: false of type Bool
Just to be clear about the types and sizes of variables that are being used:
typeof(N) # = Int64
typeof(inputS) # = Array{Float64,1}
size(inputS) # = (11,)
typeof(s) # = Array{Float64,1}
size(s) # = (11,)
Someone can help me please?
Thank you,
Tiago