【问题标题】:Trouble with DifferentialEquations.jl微分方程.jl 的问题
【发布时间】:2017-05-10 08:02:30
【问题描述】:

我对 Julia 很陌生,我目前正在学习如何用它来求解微分方程。我尝试运行 Christopher Rackauckas 的简单预制代码,但出现错误。代码可以在here找到。我这里也写一下:

using DifferentialEquations
alpha = 0.5 #Setting alpha to 1/2
f(y,t) = alpha*y
u0 = 1.5
prob = ODEProblem(f,u0)
timespan = [0,1] # Solve from time = 0 to time = 1
sol = solve(prob,timespan) # Solves the ODE
using Plots
plot(sol) # Plots the solution using Plots.jl

我得到的错误如下所示:

LoadError: MethodError: nomethof matching DiffEqBase.ODEProblem{uType,tType,isinplace,FC;MM}(::#f, ::Float64)

我也尝试运行其他类似的代码,甚至删除了 DifferentialEquations.jl -package 然后重新安装它,但没有任何改变。

有没有经验丰富的人知道我可能做错了什么?

【问题讨论】:

    标签: julia differential-equations differentialequations.jl


    【解决方案1】:

    问题是那篇博文来自很久以前。或者至少,DifferentialEquations 1.0 在这部分有一些重大变化。您应该使用the tutorial instead,它将此示例修复为最新版本。解决办法是:

    using DifferentialEquations
    alpha = 0.5 #Setting alpha to 1/2
    f(y,t) = alpha*y
    u0 = 1.5
    tspan = (0.0,1.0) # Solve from time = 0 to time = 1
    prob = ODEProblem(f,u0,tspan)
    sol = solve(prob) # Solves the ODE
    using Plots
    plot(sol) # Plots the solution using Plots.jl
    

    但现在我知道人们仍在查看那个旧帖子,我更新了它的语法以使其正确。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-20
      • 1970-01-01
      相关资源
      最近更新 更多