ode113
Solve a system of non-stiff differential equations.
Syntax
[t,y] = ode113(@func,tin,y0)
[t,y] = ode113(@func,tin,y0,options)
[t,y,te,ye,ie] = ode113(...)
Inputs
- func
- The system of equations to solve.
- tin
- The vector of times (or other domain variable) at which to report the solution. If the vector has two elements then the solver will operate in single step mode and determine appropriate intermediate steps.
- y0
- The vector of initial conditions.
- options
- A struct containing options settings specified via odeset.
Outputs
- t
- The times at which the solution is computed.
- y
- The solution matrix, with the solution at each time stored by row.
- te
- The index of the event that recorded each zero value.
- ye
- The system function values corresponding to each te value.
- ie
- The event index corresponding to each zero value.
Example
Find the transient current in a series RLC circuit.
function dy = RLC(t,y,R,L,C)
% y = [i, di/dt]
dy = [0, 0];
dy(1) = y(2);
dy(2) = -y(1)/(L*C) - y(2)*(R/L);
end
v = 2.4; % volts
R = 1.1; % resistor
L = 1.6; % inductor
C = 0.8; % capacitor
handle = @(t,y) RLC(t,y,R,L,C);
t = [0:0.2:12]; % time vector
yi = [0, v/L];
[t,y] = ode113(handle,t,yi);
i = y(:,1)'
i = [Matrix] 1 x 61
0.00000 0.27884 0.51377 0.70351 0.84839 0.94995 1.01078 1.03433 1.02469
0.98645 0.92434 0.84325 0.74801 0.64324 0.53316 0.42164 0.31224 0.20786
0.11085 0.02308 -0.05406 -0.11968 -0.17334 -0.21506 -0.24514 -0.26416
-0.27303 -0.27276 -0.26465 -0.24991 -0.22977 -0.20556 -0.17843 -0.14961
-0.12013 -0.09095 -0.06290 -0.03664 -0.01271 0.00850 0.02673 0.04184
0.05377 0.06262 0.06849 0.07160 0.07223 0.07066 0.06726 0.06234 0.05623
0.04928 0.04178 0.03403 0.02628 0.01877 0.01168 0.00517 -0.00065 -0.00570
-0.00994
Comments
ode113 solves the system using the Adams method algorithm from the Sundials CVODE library.
To pass additional parameters to a function argument, use an anonymous function.
- RelTol: 1.0e-3
- AbsTol: 1.0e-6
The 'Events' function used with the last three output arguments is specified using odeset.