ode

Solving an ODE when the function is given as discrete values -matlab-

走远了吗. 提交于 2019-11-26 22:15:04
问题 I have the following ODE: x_dot = 3*x.^0.5-2*x.^1.5 % (Equation 1) I am using ode45 to solve it. My solution is given as a vector of dim(k x 1) (usually k = 41, which is given by the tspan ). On the other hand, I have made a model that approximates the model from (1), but in order to compare how accurate this second model is, I want to solve it (solve the second ODE) by means of ode45 . My problem is that this second ode is given discrete: x_dot = f(x) % (Equation 2) f is discrete and not a

Using event function in matlab ode45 for multi-dimensional state vector

蓝咒 提交于 2019-11-26 22:11:03
问题 I have a set of odes written in matrix form as $X' = AX$; I also have a desired value of the states $X_des$. $X$ is a five dimensional vector. I want to stop the integration after all the states reach their desired values (or atleast close to them by $1e{-3}$). How do I use event function in matlab to do this? (All the help I have seen are about 1 dimensional states) PS: I know for sure that all the states approach their desired values after long time. I just want to stop the integration once

Odd SciPy ODE Integration error

让人想犯罪 __ 提交于 2019-11-26 20:58:30
问题 I'm implementing a very simple Susceptible-Infected-Recovered model with a steady population for an idle side project - normally a pretty trivial task. But I'm running into solver errors using either PysCeS or SciPy, both of which use lsoda as their underlying solver. This only happens for particular values of a parameter, and I'm stumped as to why. The code I'm using is as follows: import numpy as np from pylab import * import scipy.integrate as spi #Parameter Values S0 = 99. I0 = 1. R0 = 0.

Matlab ode45. How to change a parameter inside it while calling it?

我只是一个虾纸丫 提交于 2019-11-26 18:33:01
问题 I'm new with Matlab. I hope you can help me. I have to solve a system of ODEs using ODE45 function. Here is the function which describes my equitions. function dNdt = rateEquations(t, y) %populations of corresponding state Ng = y(1); Ns = y(2); Nt = y(3); %All constants used are dropped for the sake of easy reading. Note the parameter F. %rate equations dNs = s0 * Ng * F - Ns/ t_S1; dNt = Ns / t_ISC - Nt / t_T1; dNg = -dNt - dNs; dNdt = [dNg; dNs; dNt]; end Then, in my script .m-file i call

Matlab ode solvers: changing state and specified time

青春壹個敷衍的年華 提交于 2019-11-26 06:09:05
问题 I am solving a set of ODEs (dy/dt) at t=0, all initial conditions t=0 y_0=(0,0,0). Can I add some number to the y values at different times (e.g., at t=10, y1 should be added to that number; at t=20, y2 should be added to that number, etc.) and solve the equations? 回答1: Inserting large discontinuities in your ODE in the way you suggest (and the way illustrated by @macduff) can lead to less precision and longer computation times (especially with ode45 - ode15s might be a better option or at