numerical-integration

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

Calculate the Area under a Curve

旧城冷巷雨未停 提交于 2019-11-26 12:07:54
I would like to calculate the area under a curve to do integration without defining a function such as in integrate() . My data looks as this: Date Strike Volatility 2003-01-01 20 0.2 2003-01-01 30 0.3 2003-01-01 40 0.4 etc. I plotted plot(strike, volatility) to look at the volatility smile. Is there a way to integrate this plotted "curve"? Joris Meys The AUC is approximated pretty easily by looking at a lot of trapezium figures, each time bound between x_i , x_{i+1} , y{i+1} and y_i . Using the rollmean of the zoo package, you can do: library(zoo) x <- 1:10 y <- 3*x+25 id <- order(x) AUC <-

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