Difference between bvp4c and ode15s

1 view (last 30 days)
Joshua
Joshua on 13 Jul 2012
Hi, I'm getting differing results from bvp4c and ode15s. I've used bvp4c to produce an estimate of the solution to a set of equations. I've then used the initial conditions for this given solution and plugged it into ode15s. However, when I compare the results, they look nothing alike. Am I doing something wrong?
This function produces a 2x2 plot with the top pair being the results of the bvp4c and the bottom pair being the results of ode15s. Theoretically, they should be the same.
Any help would be appreciated. Thanks!
function [sol T Y] = fhn4bvp
solinit = bvpinit(linspace(0, 30, 250), @fhn4init);
sol = bvp4c(@fhn4ode, @fhn4bc, solinit);
figure;
subplot(2, 2, 1); plot(sol.x, sol.y(1, :) / 2);
subplot(2, 2, 2); plot(sol.y(3, :), sol.y(4, :)); axis([-2 2 -0.6 1.5])
% putting it back into the FHN
[T Y] = ode15s(@(t, y) fhn4ode(t, y), [0 30], [sol.y(1, 1) sol.y(2, 1) sol.y(3, 1), sol.y(4, 1)]);
%[T Y] = ode15s(@(t, y) fhn(t, y, sol.x, sol.y(1, :) / 2), [0 30], [0.95836586 -0.322958325]);
subplot(2, 2, 3); plot(T, Y(:, 1));
subplot(2, 2, 4); plot(Y(:, 3), Y(:, 4));
function res = fhn4bc(ya,yb)
res = [ ya(3) - 0.95836586
ya(4) + 0.322958325
yb(3) - 0.8909
yb(4) + 0.4062 ];
function yinit = fhn4init(x)
amp = 0.000;
yinit = [ amp * cos( 2 * pi * x / 15 )
amp * sin( 2 * pi * x / 15 )
amp * cos( 2 * pi * x / 15 )
amp * sin( 2 * pi * x / 15 ) ];
% lambda_x = y(1); lambda_y = y(2); x = y(3); y = y(4)
function fhnsol = fhn4ode(t, y)
a = 0.7; b = 0.8; c = 3.0; r = 0.342;
fhnsol = [ -c * (1 - y(3)^2) * y(1) + y(2) / c
-c * y(1) + b * y(2) / c
c * (y(4) + y(3) - y(3)^3 / 3 - r) + y(1) / 2
-(y(3) - a + b * y(4)) / c ];

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!