Difference between bvp4c and ode15s
1 次查看(过去 30 天)
显示 更早的评论
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 ];
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!