Then I fail to see the problem.
You want only the solution at the end point.
[t,y] = ode45(odefun,[0,2],1)
t =
0
0.0500
0.1000
0.1500
0.2000
0.2500
0.3000
0.3500
0.4000
0.4500
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
y =
1.0000
1.0525
1.1103
1.1737
1.2428
1.3181
1.3997
1.4881
1.5836
1.6866
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Multiple time steps were generated. So what? TAKE THE LAST ONE.
Is it correct?
What is the problem? This works, basically always. It gave you more information than you wanted, wringing your hands with worry. Take the result you want to see, and ignore the rest.
If it really, really, really, desperately, upsets you that you need to do that extra step, then wrap the ODE solver in a caller function, that does exactly that, returning only the final element of y. Again, what is the problem?
function yfinal = myode45(odefun,tspan,y0)
[t,y] = ode45(odefun,tspan,y0);