A simple first order ode evaluated at specific points
In Post 648 , we integrated an ODE over a specific time span. Sometimes it is desirable to get the solution at specific points, e.g. at t = [0 0.2 0.4 0.8]; This could be desirable to compare with experimental measurements at those time points. This post demonstrates how to do that.
The initial condition is y(0) = 1.
close all; clc; y0 = 1; % initial condition y(t=t0) tspan = [0 0.2 0.4 0.8]; % the solution will only be evaluated at these % points. [t,y] = ode45(@myode,tspan,y0); plot(t,y,'ko-') xlabel('time') ylabel('y(t)')
ans = end
function dydt = myode(t,y) % differential equation to solve dydt = y; % categories: ODEs % tags: math