odephas2

ODE output function: 2-D phase plane plot, drawn while the solver runs.

Category: Other public functions: funfun

Syntax

status = odephas2(t, y, flag)

Output-function form: called by the solver at the start, at each accepted step and at the end.

Description

Pass @odephas2 as the 'OutputFcn' option of odeset and the solver calls it at every step. It draws the first state component against the second, which shows the trajectory of a two-variable system, such as an oscillator, as a curve in the phase plane. The solver, not the user, normally invokes it.

For three states use odephas3. To plot every component against time use odeplot.

Input arguments

t, y
Time points and state columns passed in by the solver.
flag
'init', '' or 'done', telling which phase the solver is in.

Output arguments

status
Logical, true to ask the solver to stop. The plotting functions always return false.

Example

Phase portrait of an oscillator

opts = odeset('OutputFcn', @odephas2);
[t, y] = ode45(@(t, y) [y(2); -y(1)], [0 10], [1; 0], opts);

In the app, the phase-plane curve (a circle) is drawn below the code.

See also

odephas3 odeplot odeprint odeset ode45