/usr/share/octave/packages/odepkg-0.8.4/odepkg_examples_dde.m is in octave-odepkg 0.8.4-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | %# Copyright (C) 2008-2012, Thomas Treichl <treichl@users.sourceforge.net>
%# OdePkg - A package for solving ordinary differential equations and more
%#
%# This program is free software; you can redistribute it and/or modify
%# it under the terms of the GNU General Public License as published by
%# the Free Software Foundation; either version 2 of the License, or
%# (at your option) any later version.
%#
%# This program is distributed in the hope that it will be useful,
%# but WITHOUT ANY WARRANTY; without even the implied warranty of
%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%# GNU General Public License for more details.
%#
%# You should have received a copy of the GNU General Public License
%# along with this program; If not, see <http://www.gnu.org/licenses/>.
%# -*- texinfo -*-
%# @deftypefn {Function File} {[@var{}] =} odepkg_examples_dde (@var{})
%# Open the DDE examples menu and allow the user to select a demo that will be evaluated.
%# @end deftypefn
function [] = odepkg_examples_dde ()
vode = 1; while (vode > 0)
clc;
fprintf (1, ...
['DDE examples menu:\n', ...
'==================\n', ...
'\n', ...
' (1) Solve a simple "exp(...)" example with solver "ode23d"\n', ...
' (2) Solve an example from Wille and Baker with solver "ode45d"\n', ...
' (3) Solve an example from Hu and Wang with solver "ode54d"\n', ...
' (4) Solve the "infectious disease model" with solver "ode78d"\n', ...
'\n', ...
' Note: There are further DDE examples available with the OdePkg\n', ...
' testsuite functions.\n', ...
'\n', ...
' If you have another interesting DDE example that you would like\n', ...
' to share then please modify this file, create a patch and send\n', ...
' your patch with your added example to the OdePkg developer team.\n', ...
'\n' ]);
vode = input ('Please choose a number from above or press <Enter> to return: ');
clc; if (vode > 0 && vode < 5)
%# We can't use the function 'demo' directly here because it does
%# not allow to run other functions within a demo.
vexa = example (mfilename (), vode);
disp (vexa); eval (vexa);
input ('Press <Enter> to continue: ');
end %# if (vode > 0)
end %# while (vode > 0)
%!demo
%! # Solves a simple example where the delay differential equation is
%! # of the form yd = e^(-lambda*t) - y(t-tau).
%!
%! function [vyd] = fexp (vt, vy, vz, varargin)
%! vlambda = varargin{1};
%! vyd = exp (- vlambda * vt) - vz(1);
%! endfunction
%!
%! vtslot = [0, 15]; vlambda = 1; vinit = 10;
%! vopt = odeset ('NormControl', 'on', 'RelTol', 1e-4, 'AbsTol', 1e-4);
%! vsol = ode23d (@fexp, vtslot, vinit, vlambda, vinit, vopt, vlambda);
%! plot (vsol.x, vsol.y);
%!demo
%! # Solves the example 3 from the publication 'DELSOL - a numerical
%! # code for the solution of systems of delay-differential equations'
%! # from the authors David Wille and Christopher Baker.
%!
%! function [vyd] = fdelsol (vt, vy, vz, varargin)
%! %# vy is a column vector of size (3,1)
%! %# vz is the history of size (3,2)
%! vyd = [vz(1,1); vz(1,1) + vz(2,2); vy(2,1)];
%! endfunction
%!
%! vopt = odeset ('NormControl', 'on', 'MaxStep', 0.1, 'InitialStep', 0.01);
%! vsol = ode45d (@fdelsol, [0, 5], [1, 1, 1], [1, 0.2], ones(3,2), vopt);
%! plot (vsol.x, vsol.y);
%!demo
%! # Solves the examples 2.3.1 and 2.3.2 from the book 'Dynamics of
%! # Controlled Mechanical Systems with Delayed Feedback' from the
%! # authors Haiyan Hu and Zaihua Wang.
%!
%! function [vyd] = fhuwang1 (vt, vy, vz, varargin)
%! %# vy is of size (1,1), vz is of size (1,1)
%! vyd = (vz(1,1) - varargin{1})^(1/3);
%! endfunction
%!
%! function [vyd] = fhuwang2 (vt, vy, vz, varargin)
%! %# vy is of size (1,1), vz is of size (1,1)
%! vyd = (vy - vz)^(1/3);
%! endfunction
%!
%! vtslot = [0, 10]; vK = 1; vinit = 1; vhist = 0;
%! vopt = odeset ('NormControl', 'on', 'RelTol', 1e-6, 'InitialStep', 0.1);
%!
%! vsol = ode54d (@fhuwang1, vtslot, vK, vinit, vhist, vopt, vK);
%! plot (vsol.x, vsol.y, 'ko-', 'markersize', 1); hold;
%!
%! vsol = ode54d (@fhuwang2, vtslot, vK, vinit, vhist, vopt, vK);
%! plot (vsol.x, vsol.y, 'bx-', 'markersize', 1);
%!demo
%! # Solves the infectious disease model from the book 'Solving Ordinary
%! # Differential Equations 1' from the authors Ernst Hairer and Gerhard
%! # Wanner.
%!
%! function [vyd] = finfect (vx, vy, vz, varargin)
%! %# vy is of size (3,1), vz is of size (3,2)
%! vyd = [ - vy(1) * vz(2,1) + vz(2,2);
%! vy(1) * vz(2,1) - vy(2);
%! vy(2) - vz(2,2) ];
%! endfunction
%!
%! function [vval, vtrm, vdir] = fevent (vx, vy, vz, varargin)
%! %# vy is of size (3,1), vz is of size (3,2)
%! vfec = finfect (vx, vy, vz);
%! vval = vfec(2:3); %# Have a look at component two + three
%! vtrm = zeros(1,2); %# Don't stop if an event is found
%! vdir = -ones(1,2); %# Check only for falling direction
%! endfunction
%!
%! vopt = odeset ('InitialStep', 1e-3, 'Events', @fevent);
%! vsol = ode78d (@finfect, [0, 40], [5, 0.1, 1], [1, 10], ...
%! [5, 5; 0.1, 0.1; 1, 1], vopt);
%! plot (vsol.x, vsol.y, 'k-', vsol.xe, vsol.ye, 'ro');
%# Local Variables: ***
%# mode: octave ***
%# End: ***
|