#
# vanderpol_demo.m
#
# Octave demonstration script that uses the vector field
# defined in vanderpol.m
#
# This file was generated by the program VFGEN, version: 2.5.0
# Generated on 15-Jan-2015 at 14:31
#
# Global vector for the parameters.
global vanderpol_parameters;
# Load the vector field definition and the jacobian.
source "vanderpol.m";
# --- Parameters ---
vanderpol_parameters(1) = 0.2; # epsilon
# --- Initial conditions ---
x_(1) = 0.01;
x_(2) = 0;
# --- Time values ---
t0_ = 0.0;
t1_ = 10.0;
numpoints = 201;
t_ = linspace(t0_, t1_, numpoints);
# --- Solver error tolerances ---
lsode_options("relative tolerance", 1e-6);
lsode_options("absolute tolerance", 1e-8);
# --- Call the ODE solver ---
xsol_ = lsode({"vanderpol_vf", "vanderpol_jac"}, x_, t_);
# --- Plot the solution ---
args = argv();
fig = figure;
if length(args) == 1
set(fig, "visible", "off")
end
plot(t_, xsol_(1:end, 1), "b;x;", "linewidth", 1)
hold on
plot(t_, xsol_(1:end, 2), "g;y;", "linewidth", 1)
grid on
xlabel("t")
if length(args) == 1
print(args{1})
end