We deliver solutions for the AI eraâcombining symbolic computation, data-driven insights and deep technical expertise
is an option for NDSolve and other functions that specifies variables that only change at discrete times in a temporal integration.
DetailsIncrement a discrete variable at regular time intervals:
Increment a discrete variable when the solution crosses 0:
Modify multiple discrete variables simultaneously when the solution crosses 0:
This time, enact the change in before modifying :
Stop the integration when a discrete variable goes out of the discrete range {1,2,3}:
Stop when the discrete variable goes out of the continuous range :
Print a message when out of range, but continue integrating the equation:
The initial condition is also out of range:
Discrete variables can take on non-numerical values:
Allow sliding mode solutions by using the action "DiscontinuitySignature":
Plot the vector field and solution:
The value of the discrete variable is 0 when the solution is in sliding mode:
Set the discontinuity state variable when reaches a sliding discontinuity curve :
Applications (5)Switch between two right sides of a differential equation using a discrete variable:
Set up a differential equation that switches between multiple right sides:
Simulate a ball bouncing down steps:
Plot the ball's kinetic, potential, and total energy:
Simulate the system stabilized with a discrete-time controller :
Change the wave speed at in a wave equation:
Properties & Relations (1)NDSolve automatically handles discontinuous functions like Sign using discrete variables:
Use "DiscontinuitySignature" with a discrete variable to emulate the Sign function:
Possible Issues (3)When a discrete variable goes out of range, a message is displayed and the integration halts:
Derivatives of discrete variables cannot appear in the equations passed to NDSolve:
Discrete variables with "DiscontinuitySignature" action must have range {-1,0,1}:
If the range is {-1,1}, the sliding mode solution will not be found:
Specify the range as Element[a,{-1,0,1}] for sliding mode solutions:
Wolfram Research (2012), DiscreteVariables, Wolfram Language function, https://reference.wolfram.com/language/ref/DiscreteVariables.html. TextWolfram Research (2012), DiscreteVariables, Wolfram Language function, https://reference.wolfram.com/language/ref/DiscreteVariables.html.
CMSWolfram Language. 2012. "DiscreteVariables." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DiscreteVariables.html.
APAWolfram Language. (2012). DiscreteVariables. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DiscreteVariables.html
BibTeX@misc{reference.wolfram_2025_discretevariables, author="Wolfram Research", title="{DiscreteVariables}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/DiscreteVariables.html}", note=[Accessed: 17-August-2025]}
BibLaTeX@online{reference.wolfram_2025_discretevariables, organization={Wolfram Research}, title={DiscreteVariables}, year={2012}, url={https://reference.wolfram.com/language/ref/DiscreteVariables.html}, note=[Accessed: 17-August-2025]}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4