https://github.com/mathworks-teaching-resources/phase-plane-and-slope-field
Apps for qualitative ODE analysis.
https://github.com/mathworks-teaching-resources/phase-plane-and-slope-field
app courseware cwm matlab odes
Last synced: about 24 hours ago
JSON representation
Apps for qualitative ODE analysis.
- Host: GitHub
- URL: https://github.com/mathworks-teaching-resources/phase-plane-and-slope-field
- Owner: MathWorks-Teaching-Resources
- License: bsd-3-clause
- Created: 2021-05-05T13:15:57.000Z (almost 4 years ago)
- Default Branch: release
- Last Pushed: 2023-11-17T22:55:56.000Z (over 1 year ago)
- Last Synced: 2025-04-23T00:45:00.290Z (about 24 hours ago)
- Topics: app, courseware, cwm, matlab, odes
- Homepage:
- Size: 34.1 MB
- Stars: 76
- Watchers: 5
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Phase Plane and Slope Field
[](https://www.mathworks.com/matlabcentral/fileexchange/91705-phase-plane-and-slope-field-apps) or [](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Phase-Plane-and-Slope-Field)
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]](#ref1). 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.2.0
* Updated to offer both dark mode and light mode for plotting region.
* Removed unused function in Phase Plane app.
* Improved user message when changing the solver field density slider.
* Fixed case choices on slider labels to be consistent with each other.
* Removed ode15i from offered solvers because it is an implicit solver that requires a different equation structure than these apps are designed to study.### Previous 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
* Qualitative Analysis of ODEs:
an accompanying set of live scripts that teach the basics of qualitative ODE analysis using these apps.### 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. [](https://matlab.mathworks.com/open/github/v1?repo=MathWorks-Teaching-Resources/Phase-Plane-and-Slope-Field)
2. Double-click each app installer (SlopeField.mlappinstall and PhasePlane.mlappinstall) and follow the installation instructions.
3. 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.https://user-images.githubusercontent.com/81383420/134724074-25ac1212-2aa7-429b-b93d-550667641cf7.mp4
https://user-images.githubusercontent.com/81383420/134727298-5e0c2e62-4e4b-452d-9371-c61237e395e0.mp4
### Quick Start Guides
As an alternative to the videos, you can use these PDF quick start guides to get up and running quickly.[
](https://github.com/MathWorks-Teaching-Resources/Phase-Plane-and-Slope-Field/files/6429294/PhasePlaneQuickStart.pdf)
[](https://github.com/MathWorks-Teaching-Resources/Phase-Plane-and-Slope-Field/files/6429351/SlopeFieldQuickStart.pdf)
## 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](LICENSE.md) file in this GitHub repository.## Educator Resources ##
* [Featured Courseware](https://www.mathworks.com/academia/courseware/course-materials.html)
* [Teach with MATLAB and Simulink](https://www.mathworks.com/academia/educators.html)
* [MATLAB Grader](https://www.mathworks.com/products/matlab-grader.html)Find an issue or need help? Email the MathWorks teaching resources team:
[email protected]If you want to contribute directly to this project, you can find information about how to do so in the [CONTRIBUTING.md](CONTRIBUTING.md) page on GitHub.
## 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

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 UpdateClear the differential equation system and parameter fields
Click ClearUse the default ODE system
Click Default### Phase Plane Panel
FunctionalityAction
Generate a solution
Click the phase plane
Delete a solution
Right-click a solution curve
Highlight a solution
Left-click a solution curveRemove highlighting
Left- or right-click a highlighted curveSolve 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 solutionsShow the analysis for an equilibrium point
Click an equilibrium point (equilibria are generated from the Analysis menu)### Appearance Tab
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 ymaxChange 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 checkboxIncrease or decrease the widths of solution curves
Use the spinner or type a new value for Line widthIncrease or decrease the number of field arrows
Use the spinner or type a new value for Field densityIncrease or decrease the size of the field arrows
Use the spinner or type a new value for Field scale### Solution Tab
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
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
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 equilibriaSolve 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 separatricesShow 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
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
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 light mode
Select Light mode
Toggle between showing the field arrows with magnitude and orientation and orientation only
Select Field orientation onlyNote: At most, one of the Dark and Light modes can be selected simultaneously. Selecting one will clear the other. The original theme colors are used if both Dark mode and Light mode are unselected.
### Library and Custom Library Menus
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
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 PNGExport 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 SVGExport the phase plane portrait and time series to a PDF. This method includes the equations in the exported image.
Select Export to PDFExport the phase plane portrait to an image file
Select Export portrait only to PNGExport the phase plane portrait to a scalable vector graphics file
Select Export portrait only to SVGExport 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
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 UpdateClear the differential equation and parameters
Click ClearUse the default ODE
Click Default### Slope Field Panel
FunctionalityAction
Generate a solution
Click the slope field
Delete a solution
Right-click a solution curve
Highlight a solution
Left-click a solution curveRemove highlighting
Left- or right-click a highlighted curveSolve 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
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 sliderIncrease or decrease the widths of solution curves
Use the spinner or type a new value for Line widthIncrease or decrease the number of slope field arrows
Use the spinner or type a new value for Field densityIncrease or decrease the size of the slope field arrows
Use the spinner or type a new value for Field scale### Solution Tab
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
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
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
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
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 light mode
Select Light mode
Toggle between showing the field arrows with magnitude and orientation and orientation only
Select Field orientation onlyNote: At most, one of the Dark and Light modes can be selected simultaneously. Selecting one will clear the other. The original theme colors are used if both Dark mode and Light mode are unselected.
### Library and Custom Library Menus
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
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 2023 The MathWorks, Inc.