Outputs of the ode45 is not matching with the known results.
3 views (last 30 days)
Show older comments
Emre Hakan Demirli
on 18 Nov 2020
Commented: Emre Hakan Demirli
on 19 Nov 2020
Outputs of the ode45 is not matching with the known results.
What I did:
Symbolic expression of the solution is when t = -0.2 we get.
According to ode45 when t=-0.2 we get.
%odefun.m
function dxdt = odefun(t,x)
dxdt = zeros(2,1);
dxdt(1) = 6*x(1)-2*x(2);
dxdt(2) = -2*x(1)+9*x(2);
end
%lscr.mlx
tspan = -1:0.001:0.5;
[t,x] = ode45(@odefun, tspan, [0 ;5]);
[t(801),x(801,1),x(801,2)] %t=-0.2 at 801th row
I verified the symbolic solution by hand calculations and Phyton. Thus, I probably made a syntax error/misuse or misinterpreted the documentation.
0 Comments
Accepted Answer
Alan Stevens
on 19 Nov 2020
Use
tspan = 0:-0.001:-1;
to get the correct values for negative values of t.
2 Comments
Walter Roberson
on 19 Nov 2020
Possibly. What needs to be the case is that the first time in tspan needs to be the same as the time that the boundary condition is for. If the boundary condition is for time 0 then Alan's suggestion is the right choice
More Answers (0)
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!