Mercurial > octave
comparison scripts/ode/odeplot.m @ 31265:c332a2f2959f
Clean up odeplot tests and demos (bug #63063)
* ode23.m, ode23s.m, ode45.m: Remove odeplot tests.
* odeplot.m: Convert inpot syntax test into a demo.
author | Ken Marek <marek_ka@mercer.edu> |
---|---|
date | Thu, 06 Oct 2022 16:36:29 -0400 |
parents | 449ed6f427cb |
children | 597f3ee61a48 |
comparison
equal
deleted
inserted
replaced
31264:af3752d9a59f | 31265:c332a2f2959f |
---|---|
116 | 116 |
117 %!demo | 117 %!demo |
118 %! ## Solve an anonymous implementation of the Van der Pol equation | 118 %! ## Solve an anonymous implementation of the Van der Pol equation |
119 %! ## and display the results while solving | 119 %! ## and display the results while solving |
120 %! fvdp = @(t,y) [y(2); (1 - y(1)^2) * y(2) - y(1)]; | 120 %! fvdp = @(t,y) [y(2); (1 - y(1)^2) * y(2) - y(1)]; |
121 %! opt = odeset ("OutputFcn", @odeplot, "RelTol", 1e-6); | 121 %! opt = odeset ("RelTol", 1e-6); |
122 %! sol = ode45 (fvdp, [0 20], [2 0], opt); | 122 %! ode45 (fvdp, [0 20], [2 0], opt); |
123 | 123 |
124 ## FIXME: convert to demo or a visible=off test with failable assert/error | 124 %!demo |
125 ## statemments | 125 %! ## Demonstrate simple multi-curve plot from t = 0 to 2 using initial, |
126 ## Test that the function works for expected ode OutputFcn calls | 126 %! ## intermediate, and terminating odeplot calling syntaxes. |
127 ## %!test | 127 %! t = linspace(0,2,10); |
128 ## %! t = linspace(0,2,10); | 128 %! y = [0.2*t; -0.1*t.^2-1; sin(t)]; |
129 ## %! y = [0.2*t; -0.1*t.^2-1; sin(t)]; | 129 %! |
130 ## %! odeplot ([0 2], y(:,1), "init"); | 130 %! disp("Plot initial points\n"); |
131 ## %! odeplot (t(2), y(:,2), []); | 131 %! odeplot ([0 2], y(:,1), "init"); |
132 ## %! odeplot (t(3:end), y(:, 3:end), []); | 132 %! title("Plot first time step"); |
133 ## %! odeplot ([], [], "done"); | 133 %! pause(1.5); |
134 ## %! close all | 134 %! |
135 %! disp("Append single time step\n"); | |
136 %! odeplot (t(2), y(:,2), []); | |
137 %! title("Append second time step"); | |
138 %! pause(1.5); | |
139 %! | |
140 %! disp("Append remaining time steps\n"); | |
141 %! odeplot (t(3:end), y(:, 3:end), []); | |
142 %! title("Plot all time steps"); | |
143 %! pause(1.5); | |
144 %! | |
145 %! disp("Terminate odeplot\n"); | |
146 %! odeplot ([], [], "done"); | |
147 %! title("Plot complete"); | |
148 |