Mercurial > octave
comparison scripts/ode/odeplot.m @ 20928:2b8447888e0a
strip trailing whitespace from files
* md5sum.m, fileattrib.m, ode23.m, odeplot.m,
ode_struct_value_check.m, runge_kutta_23.m runge_kutta_interpolate.m:
Strip trailing whitespace.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 17 Dec 2015 11:50:59 -0500 |
parents | 4d14b0a22b29 |
children | d9e05450936f |
comparison
equal
deleted
inserted
replaced
20927:1da6c81e6486 | 20928:2b8447888e0a |
---|---|
34 %# This function is called by a ode solver function if it was specified in an options structure with the @command{odeset}. This function is an internal helper function therefore it should never be necessary that this function is called directly by a user. There is only little error detection implemented in this function file to achieve the highest performance. | 34 %# This function is called by a ode solver function if it was specified in an options structure with the @command{odeset}. This function is an internal helper function therefore it should never be necessary that this function is called directly by a user. There is only little error detection implemented in this function file to achieve the highest performance. |
35 %# | 35 %# |
36 %# For example, solve an anonymous implementation of the "Van der Pol" equation and display the results while solving | 36 %# For example, solve an anonymous implementation of the "Van der Pol" equation and display the results while solving |
37 %# @example | 37 %# @example |
38 %# fvdb = @@(t,y) [y(2); (1 - y(1)^2) * y(2) - y(1)]; | 38 %# fvdb = @@(t,y) [y(2); (1 - y(1)^2) * y(2) - y(1)]; |
39 %# | 39 %# |
40 %# opt = odeset ("OutputFcn", @@odeplot, "RelTol", 1e-6); | 40 %# opt = odeset ("OutputFcn", @@odeplot, "RelTol", 1e-6); |
41 %# sol = ode45 (fvdb, [0 20], [2 0], opt); | 41 %# sol = ode45 (fvdb, [0 20], [2 0], opt); |
42 %# @end example | 42 %# @end example |
43 %# @end deftypefn | 43 %# @end deftypefn |
44 %# | 44 %# |
45 %# @seealso{odeset,odeget} | 45 %# @seealso{odeset,odeget} |
46 | 46 |
47 function [varargout] = odeplot (t, y, flag, varargin) | 47 function [varargout] = odeplot (t, y, flag, varargin) |
48 | 48 |
49 ## No input argument check is done for a higher processing speed | 49 ## No input argument check is done for a higher processing speed |
50 persistent fig; persistent told; | 50 persistent fig; persistent told; |
51 persistent yold; persistent counter; | 51 persistent yold; persistent counter; |
52 | 52 |
53 if (strcmp (flag, "init")) | 53 if (strcmp (flag, "init")) |
54 ## Nothing to return, t is either the time slot [tstart tstop] | 54 ## Nothing to return, t is either the time slot [tstart tstop] |
55 ## or [t0, t1, ..., tn], y is the inital value vector "init" | 55 ## or [t0, t1, ..., tn], y is the inital value vector "init" |
56 fig = figure; told = t(1,1); yold = y(:,1); | 56 fig = figure; told = t(1,1); yold = y(:,1); |
57 counter = 1; | 57 counter = 1; |
58 | 58 |
63 told(counter,1) = t(1,1); | 63 told(counter,1) = t(1,1); |
64 yold(:,counter) = y(:,1); | 64 yold(:,counter) = y(:,1); |
65 plot (told, yold, "-o", "markersize", 1); drawnow; | 65 plot (told, yold, "-o", "markersize", 1); drawnow; |
66 varargout{1} = false; | 66 varargout{1} = false; |
67 | 67 |
68 elseif (strcmp (flag, "done")) | 68 elseif (strcmp (flag, "done")) |
69 ## Cleanup has to be done, clear the persistent variables because | 69 ## Cleanup has to be done, clear the persistent variables because |
70 ## we don't need them anymore | 70 ## we don't need them anymore |
71 clear ("figure", "told", "yold", "counter"); | 71 clear ("figure", "told", "yold", "counter"); |
72 | 72 |
73 endif | 73 endif |