ode45

【笔记】常微分方程(1)

落花浮王杯 提交于 2020-03-06 00:16:29
表1 解常微分方程主要MATLAB指令 主题词 意义 主题词 意义 ode45 4、5阶Runge-kutta法 ode23s 刚性方程组二阶Rosenbrock法 ode23 2、3阶Runge-kutta法 ode23tb 刚性方程组低精度算法 ode113 多步Adams算法 bvpinit 边值问题预估计 odeset 解ode选项设置 bvp4c 边值问题解法 ode23t 适度刚性问题梯形算法 deval 微分方程解的求值 ode15s 刚性方程组多步Gear法 微分方程的相关知识 1、微分方程的概念 含有未知的函数及其某些阶的导数以及自变量本身的方程称为微分方程。如果未知函数是一元函数,称为常微分方程。如果未知函数是多元函数,称为偏微分方程。联系一些未知函数的一组微分方程称为微分方程组。微分方程中出现的未知函数的导数的最高阶数称为微分方程的阶。如果方程中未知函数及其各阶导数都是一次的,称为线性常微分方程。若各系数为常数,称之为常系数(或定常、自治、时不变)的。 2、初等积分法 有些方程可以直接通过积分求解。例如,一阶常系数线性常微分方程 y’=ay+b (a!=0) 可化为 dy/(ay+b)=dt 两边积分可得通解为: y(t)=Cexp(at)-a^-1b 其中C为任意常数 3、常系数线性微分方程 例1 求x’’+0.2x’+3.92x=0的通解。 解:

Solving differential equations in Matlab

孤街醉人 提交于 2020-01-25 00:19:13
问题 I need to solve these 2 differential equations simultaneously. dr^3/dt=(-3*D*Cs)/(ρ*r0^2 )*r*(1-C) dC/dt=((D*4π*r0*N*(1-C)*r)-(Af*C))/V Note: dr^3/dt is the derivative of r^3 with respect to t The two equations resemble the change in particle radius (r) and concentration (C) with time for a dissolution process of a microsuspension and its simultaneous absorption in the bloodstream. What is expected to happen as the solid dissolves, is that radius, r, will decrease and the concentration, C,

How to implement Forward Euler Method on a system of ODEs - Matlab

青春壹個敷衍的年華 提交于 2020-01-16 08:25:26
问题 I was wondering if it is possible to solve a ODE system function using the forward Euler method in the form: function [dydt] = ODEexample(t,y, AdditionalParameters) dydt(1:2) = y(3:4); dydt(3:4) = y(1:2) dydt = dydt'; end Using a Euler method such as https://nl.mathworks.com/matlabcentral/answers/366717-implementing-forward-euler-method, . I use Matlab as programming language. Or should I adjust the function? 来源: https://stackoverflow.com/questions/59333524/how-to-implement-forward-euler

How to implement Forward Euler Method on a system of ODEs - Matlab

淺唱寂寞╮ 提交于 2020-01-16 08:25:06
问题 I was wondering if it is possible to solve a ODE system function using the forward Euler method in the form: function [dydt] = ODEexample(t,y, AdditionalParameters) dydt(1:2) = y(3:4); dydt(3:4) = y(1:2) dydt = dydt'; end Using a Euler method such as https://nl.mathworks.com/matlabcentral/answers/366717-implementing-forward-euler-method, . I use Matlab as programming language. Or should I adjust the function? 来源: https://stackoverflow.com/questions/59333524/how-to-implement-forward-euler

Passing additional iteration-dependent inputs to ode45

筅森魡賤 提交于 2019-12-23 03:14:48
问题 I'm trying to solve differential equation using the ode45 function. Consider the following code, [t1,X2] = ode45(@(t,x)fun(t,x,C1,C2,C3,C4),t0,X01); where parameters C1 , C2 , C3 and C4 are column vectors, which should be available to the function that ode45 is referring to ( fun.m ). I want the values to change after every iteration, so for example, at the beginning the entry of C1 I want in is C1(1) , in the next iteration it's C1(2) , etc. How can I implement that? 回答1: You may have

ODE Times Matlab vs R

若如初见. 提交于 2019-12-12 14:24:26
问题 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 time points at which I want the ODE to return the results, i.e if I gave times = 0:50 , it would return 51 results at 0,1,2, ... 50 . Other wise I have to supply a sequence such as , times = seq(0,50,0.1) . I have a function which changes rapidly at

How to solve coupled differential equation in matlab using ode45

橙三吉。 提交于 2019-12-11 17:16:18
问题 I have two differential equations: da/dt=a(.3/a^3+.7)^1/2 and dτ/dt=1/a. The initial conditions are t=0; a=1 and τ=0, respectively. How can I solve the equations in Matlab? I need to calculate different values of a, t and τ also plot τ vs a. Thanks. 回答1: That's quite easy. First write a function to implement your differential equation and save it with a filename corresponding to the function name: function dy = my_ode(t,y) dy(1) = y(1)*(0.3/y(1)^3 + 0.)^(1/2); % a dy(2) = 1/dy(1); % tau Then

How to interpolate a vector and work with variables (ode45)?

时间秒杀一切 提交于 2019-12-11 16:19:32
问题 I'm working with an ODE model the one I have to put a vector in a variable and then solve it, but I have some parameters which depends on some of the equations of the model, like auxiliar functions/equations but I get this error: Error using Hovorka2004_Prueba>fun Too many output arguments. Error in odearguments (line 88) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0. Error in ode45 (line 114) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ... Error in

Passing additional iteration-dependent inputs to ode45

你说的曾经没有我的故事 提交于 2019-12-06 15:47:20
I'm trying to solve differential equation using the ode45 function. Consider the following code, [t1,X2] = ode45(@(t,x)fun(t,x,C1,C2,C3,C4),t0,X01); where parameters C1 , C2 , C3 and C4 are column vectors, which should be available to the function that ode45 is referring to ( fun.m ). I want the values to change after every iteration, so for example, at the beginning the entry of C1 I want in is C1(1) , in the next iteration it's C1(2) , etc. How can I implement that? You may have noticed that the official docs are not too helpful in this scenario (as they pretty much force you to use global

Imitate ode45 function from MATLAB in Python

天大地大妈咪最大 提交于 2019-12-06 14:13:06
问题 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= np.array([y[1], (1-y[0]**2)*y[1]-y[0]]) return dydt import scipy integrate l=scipy.integrate.ode(vdp1([0,20],[2,0])).set_integrator("dopri5") The results are completely different, Matlab returns different dimensions than Python. 回答1: The interface of integrate.ode is not as intuitive as of