Page 1 of 1

Matlab ode45

Posted: March 19th, 2013, 11:50 pm
by LesleYLyu
Hi all,Would someone give me some hints on how to use Matlab ode45? I checked some examples as well as matlab documentation, but still feel confused...Anyway here is what I would like to solve. I am trying to solve heston characteristic function numerically, to compare with analytical one. The system is y = [C(u,t), D(u,t)], where C(u,t) and D(u,t) satisfies:where k is constant, and a,b,c are function of u.I am confused about how to write odefun when using ode45. If a,b,c are function of t, there is example in matlab documentation, but now they are function of a variable not appearing in the system...Thanks in advance for any hints.Best

Matlab ode45

Posted: March 20th, 2013, 9:01 pm
by OOglesby
Normally, the odefun has the form: ydot = odefun(t, y). However, you can pass extra arguments into the function: ydot = odefun(t, y, arg1, arg2, argn). Below are two code examples. The first example passes in u and computes a, b, and c inside the function. The second example assumes u is constant over the integration, and therefore assumes a, b, and c are constants.I am no expert, but it seems like the resulting solution will be very smooth and continuous. If that is the case, then you get better speeds and can increase the solution accuracy by using ode113.