ode

Mathematica problems with certain differential equations and DSolve

霸气de小男生 提交于 2019-12-25 01:14:40
问题 Im having trouble getting started. I am in a Financial Engineering program, and I am trying to use a book written in 2003 to help me model partial differential equations, the black scholes model, etc. But in the introductory chapter there is a very basic ODE interest rate problem, and my output is very different from the book. DSolve[{y'[t] == ry[t], y[0] == P}, y[t], t] is what I put in. The book has a very neat solution of {{y(t)->P*exp^(rt)}} What I get is something like (Note, I can't

Solving differential equations in Matlab - In-Vitro Dissolution

戏子无情 提交于 2019-12-24 19:45:15
问题 I am trying to solve a similar problem to this one: Solving Differential Equations in Matlab However, this time the scenario is not injection of a drug into the subcutaneous tissue and its subsequent dissolution, but a more simple situation where the suspension is allowed to dissolve in a dissolution bath of volume 900 ml. function dydt=odefcnNY_v12(t,y,D,Cs,rho,r0,N,V) dydt=zeros(2,1); dydt(1)=(-D*Cs)/(rho*r0^2)*(1-y(2))*y(1)/(1e-6+y(1)^2); % dr*/dt dydt(2)=(D*4*pi*N*r0*(1-y(2))*y(1))/V; %dC

Boost odeint class with derivative and jacobian

霸气de小男生 提交于 2019-12-24 04:22:32
问题 I intend to use the Boost odeint library in an MCMC routine to estimate parameters in an ODE model. Since these ODEs may be stiff, I need to be able to pass the jacobian into the solver with the derivative. I would like to make a class which has the parameters and initial values as private members and then the derivative, jacobian, and methods to change the parameters as public methods. I tried to modify the stiff example from the odeint website to use one class containing both, but am

Solving ODE with Simulink in Matlab

半城伤御伤魂 提交于 2019-12-24 03:07:56
问题 I need to solve this ODE using Simulink and I don't know how to make it. I only know how to do it using ODE solvers. y'' - y' - 2y = e^(3x) y(0)=1, y'(0)=2. I rewrote the equation obtaining an ODEs: y' = f(x,y) y(x0) = y0 y'1 = y2 y2= e^(3*x) + y' + 2y Using ODE solver. If someone can help me to solve this using a Simulink Model I would appreciate it. I know how to solve it in Matlab using ODE solvers as ode23 and ode23s but I don't know how to do it using a Simulink Model. Thanks in advance

ODE 15s with time dependent input parameters

你说的曾经没有我的故事 提交于 2019-12-24 02:09:46
问题 I have a MATLAB code that solves a large scale ODE system of following type function [F] = myfun(t,C,u) u here is a time dependent vector used as a input in the function myfun. My current code reads as:- u = zeros(4,1); u(1) = 0.1; u(2) = 0.1; u(3) = 5.01/36; u(4) = 0.1; C0 = zeros(15*4*20+12,1); options = odeset('Mass',Mf,'RelTol',1e-5,'AbsTol',1e-5); [T,C] = ode15s(@OCFDonecolumnA, [0,5000] ,C0,options,u); I would like to have the entire time domain split into 5 different sections and have

matlab/octave random event ode45

一笑奈何 提交于 2019-12-24 02:08:11
问题 I have some troubles in understanding how to implement events in octave/matlab, in the resolution of differential equations. Consider for example this simple code to solve the differential equation y' = -y: function dy = odefun(t,y) dy = -y; endfunction options = odeset('RelTol',1e-4,'AbsTol',[1e-4]); [T,Y] = ode45(@odefun,[0 12],[1],options); Now I would like to introduce a random event. For example at some fixed time step I would like to randomly change the value of y and then continue the

integrate.ode sets t0 values outside of my data range

痞子三分冷 提交于 2019-12-23 04:05:24
问题 I would like to solve the ODE dy/dt = -2y + data(t), between t=0..3, for y(t=0)=1. I wrote the following code: import numpy as np from scipy.integrate import odeint from scipy.interpolate import interp1d t = np.linspace(0, 3, 4) data = [1, 2, 3, 4] linear_interpolation = interp1d(t, data) def func(y, t0): print 't0', t0 return -2*y + linear_interpolation(t0) soln = odeint(func, 1, t) When I run this code, I get several errors like this: ValueError: A value in x_new is above the interpolation

Solving System of Second Order Ordinary Differential Equation in Matlab

筅森魡賤 提交于 2019-12-23 04:03:10
问题 Introduction I am using Matlab to simulate some dynamic systems through numerically solving systems of Second Order Ordinary Differential Equations using ODE45. I found a great tutorial from Mathworks (link for tutorial at end) on how to do this. In the tutorial the system of equations is explicit in x and y as shown below: x''=-D(y) * x' * sqrt(x'^2 + y'^2) y''=-D(y) * y' * sqrt(x'^2 + y'^2) + g(y) Both equations above have form y'' = f(x, x', y, y') Question However, I am coming across

Matlab error in ode45 or fourth-order Runge-Kutta method to solve a system of coupled ODEs

三世轮回 提交于 2019-12-23 02:30:33
问题 I am a beginner at Matlab programming and with the Runge-Kutta method as well. I'm trying to solve a system of coupled ODEs using a 4th-order Runge-Kutta method for my project work. here is my problem... G = 1.4; g = 1.4; k = 0; z = 0; b = 0.166667; syms n; x2 = symfun(sym('x2(n)'),[n]); x1 = symfun(sym('x1(n)'),[n]); x3 = symfun(sym('x3(n)'),[n]); x4 = symfun(sym('x4(n)'),[n]); x5 = symfun(sym('x5(n)'),[n]); k1 = [x2 * x1 *n *(1 - z * x2)*(x1 - n) - 2 * x3 * n *(1 - z * x2) - x4^2 * x2 *(1 -

R: C symbol name not in load table - error in linking with external .c files

半城伤御伤魂 提交于 2019-12-22 18:33:52
问题 I am trying to use the Rsundials package to solve a system of Ordinary Differential Equations (ODEs) using SUNDIALS. First, I am trying to run the example in the manual. Rsundials can be used to solve the ODEs when the right hand side of the ODEs is described in a C file. First, the ODEs are described in a C file (example program from the package) #include "include/nvector/nvector_serial.h" #include "include/sundials/sundials_dense.h" #define Ith(v,i) ( NV_DATA_S(v)[i - 1] ) int rhs(realtype