/Phase-Plane-and-Slope-Field

Apps for qualitative ODE analysis.

OtherNOASSERTION

Phase Plane and Slope Field

View <File Exchange Title> on File Exchange

You can use the Phase Plane and Slope Field apps to qualitatively analyze ordinary differential equations (ODEs).

Phase Plane app: Analyze two-dimensional autonomous ODE systems.Slope Field app: Analyze single variable ODEs.

These apps capture the functionality of the traditional PPlane and DField apps created by John C. Polking in MATLAB between 1995 and 2003 [1]. While similar in function to the original apps, the Slope Field and Phase Plane apps have been written entirely from scratch in MATLAB App Designer using modern MATLAB coding practices. This makes the new apps easier to maintain, edit, and use.

Latest update: 1.1.0

  • Updated field arrows with solid arrowheads. These fix the distortion that was visible when the axes were scaled differently.
  • Default field color is darker. Also, an option has been added to set a custom field color (in the Appearance menu).
  • The solver now allows complex solutions but only plots the real part.
  • Added options for the numerical estimation of separatrices.
  • Added options to export the field to a figure.

Related content

Acknowledgements

  • Thank you to Roy Goodman at NJIT for his support of this project and many insightful suggestions.

Setup

MATLAB®

  1. Ensure that you have MATLAB R2021a or newer installed.
  2. Download and unzip the entire repository.
  3. Double-click each app installer (SlopeField.mlappinstall and PhasePlane.mlappinstall) and follow the installation instructions.
  4. Access the apps from the APPS tab in the MATLAB toolstrip. Use the dropdown to expand the menu.

MATLAB Online™

  1. Download and unzip the entire repository.
  2. Drag and drop the two app installers (SlopeField.mlappinstall and PhasePlane.mlappinstall) into the Current Folder in MATLAB Online.
  3. Double-click each app installer (SlopeField.mlappinstall and PhasePlane.mlappinstall) and follow the installation instructions.
  4. Access the apps from the APPS tab in the MATLAB toolstrip. Use the dropdown to expand the menu.

Getting Started

Tutorial Videos

Learn the basics of the Phase Plane and Slope Field apps in these 3-minute tutorial videos.

Phase.Plane.Tutorial.mp4
Slope.Field.Tutorial.mp4

Quick Start Guides

As an alternative to the videos, you can use these PDF quick start guides to get up and running quickly.

   

MathWorks Products

Requires MATLAB release R2021a or newer

License

The license for the Phase Plane and Slope Field apps is available in the LICENSE.md file in this GitHub repository.

Educator Resources

Find an issue or need help? Email the MathWorks Online teaching team: onlineteaching@mathworks.com


Full Capabilities: Phase Plane App

The details of the Phase Plane app are documented here for reference. The Phase Plane app has four main areas you can interact with:

Each of these areas is described below.

Differential Equation System Panel

differentialequationsystempanel

FunctionalityAction
Define an ODE system Type the two dependent variable names in the first two fields and the ODE expressions in terms of the dependent variables and any parameters you defined.
Define a parameter Type the name of the parameter in the first field. Type the value in the second field. You can use a valid MATLAB expression, such as log(2), but you cannot use other parameters or variables.
Update the phase plane field with the edited ODE system Click Update
Clear the differential equation system and parameter fields Click Clear
Use the default ODE system Click Default

Phase Plane Panel

phaseplanepanel

FunctionalityAction
Generate a solution Click the phase plane
Delete a solution Right-click a solution curve
Highlight a solution Left-click a solution curve
Remove highlighting Left- or right-click a highlighted curve
Solve from a numerically defined initial condition Set the initial values in the x0 and y0 edit fields. Then press Solve from (x0,y0).
Clear solution curves Click Clear solutions
Show the analysis for an equilibrium point Click an equilibrium point (equilibria are generated from the Analysis menu)

Appearance Tab

appearancetabpp

FunctionalityAction
Change the phase plane horizontal axis limits Type values of xmin and xmax
Change the phase plane vertical axis limits Type values of ymin and ymax
Change the time series horizontal axis limits Type values of tmin and tmax
Speed up or slow down the animation Move the Animation speed slider
Toggle the time series plots Click the Time series checkbox
Increase or decrease the widths of solution curves Use the spinner or type a new value for Line width
Increase or decrease the number of field arrows Use the spinner or type a new value for Field density
Increase or decrease the size of the field arrows Use the spinner or type a new value for Field scale

Solution Tab

solutiontabpp

FunctionalityAction
Change the solver time span. The ODE solver will start at t=0 and solve both forward and backward in time based on the defined values. Edit the Forward solution tmax and Backward solution tmin fields.
Allow the solver to continue beyond the axis limits Uncheck Terminate solutions at axis limits
Change how many solutions are generated when the Solve from region functionality is used Adjust the Solve from region density slider

Solver Tab

solvertabpp

FunctionalityAction
Change the variable step ODE solver Select a solver from the Solver dropdown
Change the ODE solver relative tolerance Enter a new value in the Relative tolerance field
Change the ODE solver absolute tolerance Enter a new value in the Absolute tolerance field
The ODE solver automatically terminates if it runs for too long (in real time). You can adjust how long the solver will run. Type a new value for Max solver wall clock (s)
Use a fixed step solver Press the Fixed step button
Use a different fixed step solver. Note that implicit methods use a Newton iteration at each step and, as a result, solve slowly. Select a solver from Solver dropdown
Use a different step in the numerical integration Type a new value for Step size

Analysis Menu

analysismenupp

FunctionalityAction
Numerically solve for an equilibrium of the system. Equilibria occur where x'(t)=0 and y'(t)=0. This function uses the Newton-Raphson method with a finite-difference Jacobian to solve for zeros of the differential equation system. Select Find nearby equilibrium. Then, click the phase plane near the suspected equilibrium point.
Find equilibria in the phase plane. This method scans the plane using a grid of initial guesses and records all equilibria found. The Newton-Raphson method is used to solve for zeros of the differential equation system. Select Scan for equilibria
Clear the equilibria Select Clear equilibria
Solve for saddle separatrices. Saddle separatrices are numerically estimated by generating a solution an increment away from each saddle equilibrium in the directions of the eigenvectors. Before solving for saddle separatrices, you should scan for equilibria. Select Solve for saddle separatrices
Clear the separatrices Select Clear separatrices
Show nullclines or hide nullclines. Nullclines are curves along which x'(t) = 0 or y'(t) = 0. Nullclines with x'(t) = 0 are blue and those with y'(t) = 0 red. Intersections of the nullclines are equilibria since x'(t) and y'(t) are both zero. Select Show nullclines
Automatically generate isoclines. Isoclines are curves along which the phase plane field directions are constant: y'(t)/x'(t) = m. Select Auto-generate isoclines. Then, enter an integer for how many isoclines you want to generate.
Draw an isocline curve through a point. Select Draw isocline through a point. Then, click the phase plane.
Draw isoclines with specified values. Select Draw several isoclines. Then, type a list of slope values. For example: -1 3 5
Clear the isoclines Select Clear isoclines

Solve and Draw Menus

solvemenupp

FunctionalityAction
Generate several solutions starting within a region Select Solve > Solve from region. Then, click once on the phase plane to start drawing, draw your region, and click again to stop drawing.
Draw a solution on the phase plane Select Draw > Draw solution. Then, click once on the phase plane to start drawing, draw your solution, and click again to stop drawing.
Draw a solution on the phase plane and compare it to the numerical solution Select Draw > Draw and compare solution. Then, click once on the phase plane to start drawing, draw your solution, and click again to stop drawing.

Appearance Menu

appearancemenupp

FunctionalityAction
Toggle solution animations Select Animate solution
Toggle initial value labels Select Point labels
Toggle the location of the axes Select Axis through origin
Toggle dark mode Select Dark mode
Toggle between showing the field arrows with magnitude and orientation and orientation only Select Field orientation only

Library and Custom Library Menus

librarymenupp

FunctionalityAction
Set the differential equation to a standard systemSelect one of the systems from the Library menu
Add the current system to the Custom library tabSelect Custom library > Add current system
Save the current custom library to a MAT fileSelect Custom library > Save
Load a custom library MAT file (note: the custom library should be one created by the Phase Plane app)Select Custom library > Load
Clear the current custom librarySelect Custom library > Clear

Export Graphics Menu

exportgraphicsmenupp

FunctionalityAction
Export the phase plane portrait and time series to an image file. This method includes the equations in the exported image. Select Export to PNG
Export the phase plane portrait and time series to a scalable vector graphics file (this format is useful for editing or high resolution website display). This method includes the equations in the exported image. Select Export to SVG
Export the phase plane portrait and time series to a PDF. This method includes the equations in the exported image. Select Export to PDF
Export the phase plane portrait to an image file Select Export portrait only to PNG
Export the phase plane portrait to a scalable vector graphics file Select Export portrait only to SVG
Export the phase plane portrait to a PDF Select Export portrait only to PDF

Full Capabilities: Slope Field App

The details of the Slope Field app are documented here for reference. The Slope Field app has four main areas you can interact with:

Each of these areas is described below.

Differential Equation Panel

differentialequationpanel

FunctionalityAction
Define an ODE Type the dependent variable name and the ODE expression in terms of the dependent variable and the independent variable t.
Define a parameter Type the name of the parameter in the first field. Type the value in the second field. You can use a valid MATLAB expression, such as log(2), but you cannot use other parameters or variables.
Update the slope field with a new equation Click Update
Clear the differential equation and parameters Click Clear
Use the default ODE Click Default

Slope Field Panel

slopefieldpanel

FunctionalityAction
Generate a solution Click the slope field
Delete a solution Right-click a solution curve
Highlight a solution Left-click a solution curve
Remove highlighting Left- or right-click a highlighted curve
Solve from a numerically defined initial condition Set the initial values in the t0 and x0 edit fields. Then press Solve from (t0,x0).
Clear solution curves Click Clear solutions

Appearance Tab

appearancemenu

FunctionalityAction
Change the horizontal axis limits Type values of tmin and tmax
Change the vertical axis limits Type values of xmin and xmax
Speed up or slow down the animation Move the Animation speed slider
Increase or decrease the widths of solution curves Use the spinner or type a new value for Line width
Increase or decrease the number of slope field arrows Use the spinner or type a new value for Field density
Increase or decrease the size of the slope field arrows Use the spinner or type a new value for Field scale

Solution Tab

solutiontab

FunctionalityAction
Allow solver to continue beyond axis limits Uncheck Terminate solutions at axis limits
Change how many solutions are generated when the Solve from region functionality is used Adjust the Solve from region density slider

Solver Tab

solvertab

FunctionalityAction
Change the variable step ode solver Select a solver from the Solver dropdown
Change the ODE solver relative tolerance Enter a new value in the Relative tolerance field
Change the ODE solver absolute tolerance Enter a new value in the Absolute tolerance field
The ODE solver automatically terminates if it runs for too long (in real time). You can adjust how long the solver will run. Type a new value for Max solver wall clock (s)
Use a fixed step solver Press the Fixed step button
Use a different fixed step solver. Note that implicit methods use a Newton iteration at each step and, as a result, solve slowly. Select a solver from the Solver dropdown
Use a different step in the numerical integration Type a new value for Step size

Analysis Menu

analysisdropdown

FunctionalityAction
Show nullclines or hide nullclines. Nullclines are curves along which x'(t) = 0. Select Show nullclines
Automatically generate isoclines. Isoclines are curves along which the derivative is constant: x'(t) = m. Select Auto-generate isoclines. Then, enter an integer for how many isoclines you wish to generate.
Draw an isocline curve through a point. Select Draw isocline through a point. Then, click the slope field.
Draw isoclines with specified slope values. Select Draw several isoclines. Then, type a list of slope values. For example: -1 3 5
Clear the isoclines Select Clear isoclines

Solve and Draw Menus

solvemenu

FunctionalityAction
Generate several solutions starting within a region Select Solve > Solve from region. Then, click once on the slope field to start drawing, draw your region, and click again to stop drawing.
Draw a solution on the slope field Select Draw > Draw solution. Then, click once on the slope field to start drawing, draw your solution, and click again to stop drawing.
Draw a solution on the slope field and compare it to the numerical solution Select Draw > Draw and compare solution. Then, click once on the slope field to start drawing, draw your solution, and click again to stop drawing.

Appearance Menu

appearancemenu

FunctionalityAction
Toggle solution animations Select Animate solution
Toggle initial value labels Select Point labels
Toggle the location of the axes Select Axis through origin
Toggle dark mode Select Dark mode
Toggle between showing the field arrows with magnitude and orientation and orientation only Select Field orientation only

Library and Custom Library Menus

librarymenu

FunctionalityAction
Set the differential equation to a standard systemSelect one of the systems from the Library menu
Add the current system to the Custom library tabSelect Custom library > Add current system
Save the current custom library to a MAT fileSelect Custom library > Save
Load a custom library MAT file (note: the custom library should be one created by the Slope Field app)Select Custom library > Load
Clear the current custom librarySelect Custom library > Clear

Export Graphics Menu

exportgraphicsmenu

FunctionalityAction
Export the Slope Field to an image fileSelect Export to PNG
Export the Slope Field to a scalable vector graphics file (this format is useful for editing or high resolution website display)Select Export to SVG
Export the Slope Field to a PDFSelect Export to PDF

References

[1] John C. Polking. DField and PPlane [Computer software]. (1995-2003). Available online: https://math.rice.edu/~polking/odesoft/dfpp.html


Copyright 2021 The MathWorks, Inc.