You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
f(x,y) = log(x+y)
xs = 1:0.2:5
ys = 2:0.1:5
A = [f(x+y) for x in xs, y in ys]
# linear interpolation
interp_linear = LinearInterpolation((xs, ys), A)
I think the first error is that you mean f(x,y) instead of f(x+y).
but even then,
julia> A = [f(x,y) for x in xs, y in ys]
5×4 Array{Float64,2}:
1.09861 1.38629 1.60944 1.79176
1.38629 1.60944 1.79176 1.94591
1.60944 1.79176 1.94591 2.07944
1.79176 1.94591 2.07944 2.19722
1.94591 2.07944 2.19722 2.30259
julia> interp_linear = LinearInterpolation((xs, ys), A)
ERROR: MethodError: no method matching LinearInterpolation(::Tuple{UnitRange{Int64},StepRange{Int64,Int64}}, ::Array{Float64,2})
Closest candidates are:
LinearInterpolation(::T<:AbstractRange, ::Any; extrapolation_bc) where T<:AbstractRange at /Users/ivo/.julia/packages/Interpolations/qyX2d/src/convenience-constructors.jl:3
LinearInterpolation(::T<:AbstractArray, ::Any; extrapolation_bc) where T<:AbstractArray at /Users/ivo/.julia/packages/Interpolations/qyX2d/src/convenience-constructors.jl:4
LinearInterpolation(::Tuple{Vararg{T<:AbstractRange,N}}, ::Any; extrapolation_bc) where {N, T<:AbstractRange} at /Users/ivo/.julia/packages/Interpolations/qyX2d/src/convenience-constructors.jl:8
...
Stacktrace:
[1] top-level scope at none:0
ultimately, I want to find out whether I can manipulate an irregular (x,y,z) data set into a contour plot (which can accept irregular x and y, but needs a function for z, rather than a value).
The text was updated successfully, but these errors were encountered:
Modulo the comma in f, your example works for me. But I don't think you actually showed what you're trying: note the UnitRange in the signature of the MethodError.
I am trying to get the doc example to work:
I think the first error is that you mean
f(x,y)
instead off(x+y)
.but even then,
ultimately, I want to find out whether I can manipulate an irregular (x,y,z) data set into a contour plot (which can accept irregular x and y, but needs a function for z, rather than a value).
The text was updated successfully, but these errors were encountered: