MethodError: no method matching -(::LinearAlgebra

Can you explain please what is wrong with my code?

idxWindow = (-floor((N-1)/2):floor(N/2))'
for indm = 1:M
    FD = distvec_samp[indm]
    if FD .> 0
        IntegerD = floor(FD)
        FDGal = FD - IntegerD
        hIdeal = (k) -> sinc[k-FDGal]
        hApprox = hIdeal(idxWindow)
        Sig_fd[indm,:] = filter(hApprox,1,[Sig[IntegerD+1:end],zeros(1,IntegerD)])
        IntegerD = ceil(FD)
        FDGal = FD - IntegerD
        hIdeal(k) = sinc[k-FDGal] # <------ The problem is here
        hApprox = hIdeal(idxWindow) # <------- The problem is here
        Sig_fd[indm,:] = filter(hApprox,1,[zeros(1,abs(IntegerD)),Sig[1:end+IntegerD]])
    NoiseSigma = sqrt(var(Sig_fd[indm,139000:140300])*10^(-SNR/10));  # Calculated an APPROXIMATED noise sigma
    Sig_fd[indm,:] = Sig_fd[indm,:] + NoiseSigma*randn(size(Sig_fd[indm,:]))

The error:

ERROR: LoadError: MethodError: no method matching -(::LinearAlgebra.Adjoint{Float64,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}, ::Float64)
Closest candidates are:
  -(!Matched::Float64, ::Float64) at float.jl:397
  -(!Matched::Complex{Bool}, ::Real) at complex.jl:298
  -(!Matched::Missing, ::Number) at missing.jl:93
 [1] (::getfield(Main, Symbol("#hIdeal#5")))(::LinearAlgebra.Adjoint{Float64,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}) at /bfv1.jl:191
 [2] top-level scope at /bfv1.jl:192
 [3] include at ./boot.jl:317 [inlined]
 [4] include_relative(::Module, ::String) at ./loading.jl:1044
 [5] include(::Module, ::String) at ./sysimg.jl:29
 [6] exec_options(::Base.JLOptions) at ./client.jl:266
 [7] _start() at ./client.jl:425
in expression starting at /bfv1.jl:178

It’s a little hard to tell because your code is not an MWE - none of your variables are defined anywhere, and there’s a lot of most likely irrelevant stuff in there as well. Have a look at Please read: make it easier to help you to get some ideas on how to most effectively ask for help here.

That said, you method error is (reasonably) clear I would say:

no method matching -(::LinearAlgebra.Adjoint{Float64,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}, ::Float64)

It’s slightly more convoluted then it could be because your FD (presumably) is an adjoint rather than a regular matrix, but it tells you that you can’t subtract an integer from a matrix. The error is a bit easier to digest if you have a “regular” matrix:

julia> matrix = rand(3, 3)
3×3 Matrix{Float64}:
 0.936169  0.367046   0.109481
 0.763018  0.0366246  0.933463
 0.748903  0.128593   0.47728

julia> matrix - 1
ERROR: MethodError: no method matching -(::Matrix{Float64}, ::Int64)
For element-wise subtraction, use broadcasting with dot syntax: array .- scalar

And it even tells you what you should be doing if you are looking to subtract that scalar from every element of your matrix!

From the error message it looks like k is some kind of array. You cannot subtract a number (FDGal) from an array (k), you need to use broadcasting to do it element-wise, i.e., k .- FDGal (with .- instead of -).

Thank you, I changed to:

hIdeal = (k) → sinc.(k.-FDGal)
But now I get:
ERROR: MethodError: no method matching zeros(::Int64, ::Float64)
on the this line:
Sig_fd[indm,:] = filt.(hApprox,1,[zeros(1,abs(IntegerD)),Sig[1:end+IntegerD]])

It seems like you are trying to call zeros using a float, and there is not method defining how to do that (as expected). Have you checked what type IntegerD has, it seems like it might be a float.

Checking the docstring for ceil we get

help?> ceil
search: ceil replacefield! ProcessFailedException InteractiveUtils

  ceil([T,] x)
  ceil(x; digits::Integer= [, base = 10])
  ceil(x; sigdigits::Integer= [, base = 10])

  ceil(x) returns the nearest integral value of the same type as x that is
  greater than or equal to x.

  ceil(T, x) converts the result to type T, throwing an InexactError if the
  value is not representable.

where the last row is probably interesting for you.