A simple first order ode evaluated at specific points

| categories: odes | View Comments

A simple first order ode evaluated at specific points

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.

$$\frac{dy}{dt} = y(t)$$

The initial condition is y(0) = 1.

function ode_01_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)')
'end'
ans =

end

function dydt = myode(t,y)
% differential equation to solve
dydt = y;

% categories: ODEs
% tags: math
blog comments powered by Disqus