blob: 33e5e333219f1bf0710fdff3d0fa617db6d49557 (
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 when matrix is involved
clear
clc
//Definition of the function
function ydot = func(t,y)
ydot = A*y + ones(3,1);
endfunction
//Defining the matrix
A = [1 2 1;9 6 1;1 3 4];
//Initial condition
y0 = [-1;2;3];
//Start time
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");
|