Odd ODE15s behavior due to tspan argument

1 view (last 30 days)
Can anyone explain why ode15s results are sensitive to the tspan input? I thought the solver just interpolated between time points at the tspan argument pointz. But running the below (in 2017a) gives odd behaviour for me. Specifically, even at similar times the results are markedly different across each example.
% oscillating decaying function
% same function deltaT=0.01
[T1,Y1]=ode15s(@(t,x) -0.06*exp(-0.03*t)+0.2*cos(t),0:0.01:100,7);
% same function deltaT=1
[T2,Y2]=ode15s(@(t,x) -0.06*exp(-0.03*t)+0.2*cos(t),0:1:100,7);
% same function deltaT=10
[T3,Y3]=ode15s(@(t,x) -0.06*exp(-0.03*t)+0.2*cos(t),0:10:100,7);
% same function deltaT=10
[T4,Y4]=ode15s(@(t,x) -0.06*exp(-0.03*t)+0.2*cos(t),[0 100],7);
Tal=0:0.1:100;
t=0:1:100;
%analytical solution
y=5+2*exp(-0.03*t)+0.2*sin(t);
figure(gcf)
%compare all
plot(T1,Y1,T2,Y2,T3,Y3,T4,Y4,t,y)
legend({'DT=0.01','DT=1','DT=10','start and end','Analytical'})
xlabel('Time')
ylabel('Y')
figure(gcf)
  1 Comment
Richard Allen
Richard Allen on 5 Sep 2018
Edited: Richard Allen on 5 Sep 2018
Here is the output (from the MATLAB iOS App, but Mac R2017a is identical.
Richard

Sign in to comment.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!