blob: 66431a488a7657af2899dc4c317b462a297bb8e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
//This script demonstrates the use of ODE solver
clear
clc
//Definition the function.
//The function is dy/dt = cos(t)*sin(t) - tan(t) + 1
function ydot = func(t,y)
ydot = t^2*exp(-2*t) + y
endfunction
//Initial condition of the problem, a scalar or vector
y0 = -1;
//Initial time, a real scalar
t0= 0;
//The time at which the solution is computed
t = 0.2;
//Calling the ode solver
sol=ode(y0,t0,t,func);
//Displaying the solution
disp(sol,"y(t) at t = 0.2");
|