Questions tagged [ode45]
140 questions
7
votes
3 answers
Imitate ode45 function from MATLAB in Python
I am wondering how to export MATLAB function ode45 to python. According to the documentation is should be as follows:
MATLAB: [t,y]=ode45(@vdp1,[0 20],[2 0]);
Python: import numpy as np
def vdp1(t,y):
dydt=…

Migui Mag
- 187
- 1
- 3
- 13
3
votes
2 answers
ODE Times Matlab vs R
If using a variable time step solver such as ODE45 in matlab - I would define a time span for the outputs, i.e. times = [0 50], and matlab would return results at various time steps between 0 and 50.
However in R it appears I have to define the…

Sarah Halliday
- 33
- 2
3
votes
1 answer
ode45 for Langevin equation
I have a question about the use of Matlab to compute solution of stochastic differentials equations. The equations are the 2.2a,b, page 3, in this paper (PDF).
My professor suggested using ode45 with a small time step, but the results do not match…

GMV871
- 43
- 1
- 6
2
votes
2 answers
Solving 7 equations of first order equations ode45 Matlab
I am trying to solve a system with seven differential equations. And I am having a hard time grapsing the ode45 solver.
These are the equations:
ω2_dot = -0.75 ω1 ω3
ω1_dot = 0.75 ω2 ω3 + 0.2
ω3_dot = 0
q1_dot = 1/2(ω1q4 + ω2q3 - ω3q2)
q2_dot =…

SHiSA
- 45
- 5
2
votes
1 answer
Passing matrices as input in scipy.integrate.solve_ivp python
I was solving a 2DOF spring-mass-damper system given below:
These are the 2 governing Equations
I have solved it in the following way:
from scipy.integrate import solve_ivp
import numpy as np
import matplotlib.pyplot as plt
m1 = 3
m2 = 5
k1 =…
user15014634
2
votes
1 answer
Matlab - ode45 - Unable to meet integration tolerances without reducing the step size below the smallest value allowed (1.136868e-13) at time t.
I am programing a mathematical model from an article about angiogensis but when I try to plot the functions with the given parameteres and initial values, the program doesn't run for the entirety of the timespan I defined, showing a part of the…

Maria Enes
- 21
- 1
- 3
2
votes
1 answer
Solving a system of ODEs using ODE45
I am trying to learn how to use MATLAB to solve a system of differential equations (Lorenz equations) and plot each solution as a function of t
X’ = −σx + σy
Y’ = ρx − y − xz
Z’ = −βz + xy
where σ = 10, β = 8/3, and ρ = 28, as well as x(0) = −8,…

Tina
- 23
- 6
2
votes
1 answer
Using @ or '' for ode45 in Matlab?
I am a little confused as to when to use ode45(@functionname, tspan, initialvalues,...) or ode45('functionname', tspan, initial values,...). I have seen examples using both but sometimes one works and the other doesn't.
e.g.
[t,y]=ode45(@MM2,…

Richard
- 21
- 1
2
votes
1 answer
Input matrix to function file of ode45
I have a code(which requires a lot input be given by the user) which will give me a n x n matrix(say A), which I have to use to solve a system of ODEs X'=AX. How do I include this matrix A in the function file(.m file) of ode45. If I include the…

Rhinocerotidae
- 855
- 1
- 11
- 26
2
votes
1 answer
Matlab: Differential equation (ode45): Can I reverse tspan for better initial conditions?
I'm using ode45 to solve/plot a second-order differential equation in Matlab. My tspan is from 0 to 0.25. But the initial conditions near zero are ill-defined (slope goes to infinity, complex values). The conditions near 0.25 are well defined (both…

Ribbon Cable
- 23
- 3
2
votes
1 answer
Matlab ode45 vs. ode23, different solutions
I used ode45 and ode23 for a set of non-stiff differential equations. However, both methods converge to a slightly different solution. How can I find out which one is correct? See attached plot where blue is ode45, red is ode23. The dashed lines are…

Jurriën
- 199
- 1
- 2
- 16
2
votes
1 answer
Matlab - ODE45 - change the number of time steps
I have a function with the handle @func with initial condition y0 that I want to test over t = [0, tspan]. What, exactly, do I need to do to increase the number of time steps ode45 uses, without changing tspan?
I saw the MATLAB documentation of…

farid99
- 712
- 2
- 7
- 25
1
vote
0 answers
Matlab → R, lost in translation: why ode45 yields totally different results?
I am neither very familliar with coding nor stackoverflow, I am trying to replicate this following work: https://doi.org/10.1007/978-1-0716-0191-4_12 using the data provided in the book chapter.
I do not have access to MATLAB, I tried to run the…

Strack
- 21
- 3
1
vote
1 answer
How to correctly set the 'rtol' and 'atol' in scipy integration module 'solve_ivp' for solving a system of ODE with unknown analytic solution?
I was trying to reproduce some results of ode45 solver in Python using solve_ivp. Though all parameters, initial conditions, step size, and 'atol' and 'rtol' (which are 1e-6 and 1e-3) are same, I am getting different solutions. Both of the solutions…

Rebeka Sarkar
- 13
- 4
1
vote
1 answer
Solving a 4 ODE system in MATLAB using ode45
I am not very used to MATLAB and I'm trying to solve the following problem using MATLAB ode45, however, it's not working.
I was working on a problem in reaction engineering, using a Semi-Batch Reactor.
The reaction is given by
A + B ---> C + D
A is…

Charbel Nicolas
- 25
- 5