[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Working example: passing parameters to lsode - Octave
From: |
Jana |
Subject: |
Working example: passing parameters to lsode - Octave |
Date: |
Mon, 30 Dec 2019 09:21:56 -0600 (CST) |
Thought it will be useful for beginners to provide here a working example
code on lsode usage: "Test.m" calls the function file "ODE.m"
Content of "Test.m":
/*clear;
clc;
t = linspace (0, 50, 10); % Time interval for integration
y0 = [ 4; 1.1; 4 ]; % Initial condition for Y(0)
B=[77.27 8.375e-06 0.161]; % Additional fixed parameters used in ODE
funct=@(y0,t)ODE(y0,t,B); % create a function to supply to LODE
y = lsode (funct, y0, t) % Call LODE to solve*/
Content of "ODE.m":
/*function y = ODE (x, t,B)
y = zeros (3,1);
y(1) = B(1) * (x(2) - x(1)*x(2) + x(1) - B(2)*x(1)^2);
y(2) = (x(3) - x(1)*x(2) - x(2)) / B(1);
y(3) = B(3)*(x(1) - x(3));
endfunction*/
--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html