summaryrefslogtreecommitdiff
path: root/Tutorial04-ODE/Scilab_code/Tutorial4_ode_simple_plot.sce
blob: f2df913ff8e2dc3492db17992b7b10512abe64d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//This script demonstrates the use of ODE solver and computing the 
//solution at different times. The output is in the form of a plot 
//of time versus computed solution
clear 
clc

//Definition the function. 
function ydot = func(t,y)
  ydot = t^2*exp(-2*t) + y
endfunction

//Initial condition
y0 = -1;
//Start time
t0= 0;

//The array of time where the solution is computed
tf = 4:0.01:10;

//Calling the ODE solver
sol=ode(y0,t0,tf,func);


//Plotting the result
plot(tf,sol,'Linewidth',3)
xtitle('Dynamics of y','Time','y(t)')