//matlab2011b帮助文档自带的。
Example 3
This example solves an ordinary differential equation with
time-dependent terms.
Consider the following ODE, with time-dependent parameters
defined only through the set of data points given in two
vectors:
y'(t) + f(t)y(t) = g(t)
The initial condition is y(0) = 0, where the function
f(t) is defined through the n-by-1
vectors tf and f, and the function g(t)
is defined through the m-by-1 vectors tg
and g.
First, define the time-dependent parameters f(t) and
g(t) as the following:
ft = linspace(0,5,25); % Generate t for f
f = ft.^2 - ft - 3; % Generate f(t)
gt = linspace(1,6,25); % Generate t for g
g = 3*sin(gt-0.25); % Generate g(t)
Write an M-file function to interpolate the data sets specified
above to obtain th