Julia的DifferentialEquations在将解决方案转换为数组时出现问题

时间:2018-06-18 20:07:24

标签: julia differential-equations

我使用DifferentialEquations解决了微分方程组(van der Pol方程)。 我想导出解决方案。为此,我使用了convert(Array,sol),但转换后的解决方案与sol获得的解决方案不同。

有关更多说明,请参阅以下代码:

using DifferentialEquations
using Plots

function fun(du,u,p,t)
 du[1] = u[2]
 du[2] = 1000*(1-u[1]^2)*u[2]-u[1]
end

u0 = [2.0,0.0]
tspan = (0.0,3000.0)
prob = ODEProblem(fun,u0,tspan)
sol = solve(prob)

a = convert(Array,sol)#Here I tried to convert the solution to an array
plot(a[1,:])
plot(sol,vars = 1)

a = convert(Array,sol) plot(a[1,:])返回: enter image description here

plot(sol,vars = 1)返回: enter image description here

1 个答案:

答案 0 :(得分:0)

转换的解决方案与Step 9/15 : WORKDIR / Removing intermediate container 10f69d248a51 ---> d6184c6f0ceb Step 10/15 : RUN ls ---> Running in c30b23783655 bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var workdir Removing intermediate container c30b23783655 ---> fb74727468f6 Step 11/15 : RUN ls workdir ---> Running in e6bae18e3560 README.md angular.json dist dockerfile e2e index.js node_modules package-lock.json package.json src tsconfig.json tslint.json Removing intermediate container e6bae18e3560 ---> c3e1f9f77d00 Step 12/15 : RUN ls workdir/dist ---> Running in 07923b11226e 3rdpartylicenses.txt favicon.ico index.html index.js main.1c74cb5a2b3da54e1148.js package.json polyfills.479875dfe4ba221bc297.js runtime.a66f828dca56eeb90e02.js styles.34c57ab7888ec1573f9c.css Removing intermediate container 07923b11226e ---> 66ef563ba292 Step 13/15 : COPY workdir/dist dist COPY failed: stat /var/lib/docker/tmp/docker-builder326636018/workdir/dist: no such file or directory 中包含的解决方案相同。问题在于x轴中变量的步长(这里是时间)不均匀。因此,仅使用sol绘图是不够的。我们必须提供解决方案在何时具有其价值。使用plot(a[1,:])绘制正确答案。

相关问题