File Exchange

image thumbnail

Hybrid Equations Toolbox v2.04

version (6.14 MB) by Ricardo Sanfelice
Hybrid systems simulated in MATLAB/Simulink. Includes Simulink implementation and MATLAB code.


Updated 17 May 2017

View License

The Hybrid Equation (HyEQ) Toolbox is implemented in MATLAB/Simulink for the simulation of hybrid dynamical systems. This toolbox is capable of simulating individual and interconnected hybrid systems with inputs. Examples of systems that can be simulated include a bouncing ball on a moving platform, fireflies synchronizing their flashing, and more. The Simulink implementation includes four basic blocks that define the dynamics of a hybrid system. These include a flow map, flow set, jump map, and jump set. The flows and jumps of the system are computed by the integrator system which is comprised of blocks that compute the continuous dynamics of the hybrid system, trigger jumps, update the state of the system and simulation time at jumps, and stop the simulation. Also includes a “lite simulator” which allows for faster simulation without using Simulink.

Cite As

Ricardo Sanfelice (2020). Hybrid Equations Toolbox v2.04 (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (37)

Mircea Susca


@Hayatullahi, Download Hybrid Equations Toolbox v2.04 from this link

From this link, you get the CPS simulink and all.


@Hayatullahi, Yes, I face the same issue of Cyber Physical System in Hybrid Tool box.
I also could not find it the same.

Please anyone help me out.

Hanwen Zhang

Fixed, a tiny bug in the code!

Hanwen Zhang

When i run example 1_2, i got the following warning 'Done
Warning, there are some missing hybrid time domains'

I got a totally different plot of hybrid arc

I got this issues on 2016b, can you help?
> Delete installation file? Y/N [Y]: y
Removing installation file
Installation finished!
Updating the simulink library browser.
The model 'HyEQ_Optimized' was saved in a previous release. The Simulation range checking setting for
Stateflow & MATLAB Function blocks is now set to 'none'. To change Simulation range checking
diagnostic, set Simulation range checking in the Diagnostics: Data Validity pane of the Model
Configuration Parameters dialog box. For more information, see Simulation range checking.
Update completed
Error when updating simulink library browser
Successfully created search database.
See under "Help, Documentation, Supplemental Software" for more informaton.
For documentation of the HyEQ toolbox, type
web HyEQ_Toolbox_v204.html
Please, restart Matlab before use the HyEQ toolbox.

Pablo Nanez

Hi @Hayatullahi Adeyemo, sorry to hear that you are having issues with the toolbox. I just installed it in 2019b and had no issues accessing CPS library, can you explain your error/issue so we can help you?

Hayatullahi Adeyemo

Nobody seems to be ready to help me out. I installed the Toolbox but could not access the blocks in the Library to model Cyber Physical System. Let someone help me for God's Sake.

JOe Wilson

How would I get an id and password for the following:

CruzID Blue Authentication

JOe Wilson

Resolved! Moved to a writable directory.

JOe Wilson

The instructions point to the Hybrid Equations Toolbox v2.04 website for instructions about installing the compiler. However I'm not seeing any references to compiles on this website ( Is the compiler included with the HE toolbox?

"Please check on
to instructions about how to install necessary compilers for Windows and Mac."

JOe Wilson

After installing, I get the following error message. Can someone let me know the problem?

Online Course License -- for instructional use in online courses only.

>> install
Reading the archiv
Checksum test passed (1F33D97734E874)
HyEQ_Toolbox_V2_04 version 2 (04)
HyEQ_Toolbox_V2_04 time stamp 17-May-2017 11:18:43
Old HyEQ_Toolbox_V2_04 found in C:\Program Files\MATLAB\InstallHyEQ_Toolbox_V2_04
> Delete old toolbox? Y/N [Y]: y
Change to C:\Program Files\MATLAB\InstallHyEQ_Toolbox_V2_04
Error using fprintf
Invalid file identifier. Use fopen to generate a valid file identifier.

Error in install (line 749)
fprintf(fid,'%s\n','A critical error has occurred. Please inform the distributor');


Hayatullahi Adeyemo

I have installed the Hybrid Equations Toolbox v2.04 successfully on MATLAB R2019b. But I cannot locate the Cyber Physical Systems block in the Simulink Library Browser.

Ricardo Sanfelice

@Zhiliang Wang, thanks for your comments. We have tried to replicate your issue in Matlab 2018a (win10 and IOS) but we didn't get those issues. Please go to the installation folder (e.g., C:\Users\userX\Documents\MATLAB\HyEQ_Toolbox_V2_04) and uninstall the toolbox by typing in the command window >>tbclean. After that, please reinstall the toolbox and DO NOT update the Simulink library by hand. Then, restart Matlab and type in the Matlab console: >> slLibraryBrowser, you must be able to see the blocks and examples of the toolbox.

Pablo Nanez

@Sahel Eskandar, thanks for sharing your experience installing the toolbox.
From the error, I can guess that you don't have permissions to write in the folder where the toolbox is trying to install, this might be because you are trying to install from the >>matlabroot, or any folder in the Matlab's >>path, please make sure that you place the source code folder away from matlabroot and the Matlab's path (e.g., Desktop)

Sahel Eskandar

I cannot install this toolbox on Matlab R2018b
The error is:
during installation
Error using rmdir
No directories were removed.
errorcode is 93.4
A critical error has occurred. Please inform the distributor
of the toolbox, where the error occured and send us the entire
screen output of the installation, the error report report
and the informations about the toolbox (distributor, name,
URL etc.). For your convenience, this information has been
recorded in:

Provide a brief description of what you were doing when
this problem occurred.

E-mail or FAX this information to us at:
Fax: ++49 +331 288 2640

Thank you for your assistance.

Zhiliang Wang

I am using matlab 2018a. After installation, I can find documentation in help center, I can run example of jumping ball, however, I cannot find the four module in simulink library. The following messages are provided when updating the simulink library:
Error adding nodes to XML: HyEQ_Library_R2012a/HyEQ_(optimized):
A copy of the original file "HyEQ_Library_R2012a.slx" has been created because it was last saved in an earlier version of Simulink. To recover the original version, rename the file "HyEQ_Library_R2012a.slx.r2012a" as "HyEQ_Library_R2012a.slx".
How can I do?

Pablo Nanez

@Tushar Sharma, please follow the installation instructions in the pdf. You need to download and UNZIP the file and place the install.m file outside your matlab root. After that, go to that folder using matlab, and then type install in the command window, you should answer some questions and see how the installation process take place.

Tushar Sharma

I am typing install in the command window, but nothing is happening? What do I do? Is it already there in my system?

Sudeep Chandrasekaran

I tried installing this in R2018a.
OS - Ubuntu 16.04

but fails with the following exception

Caught unexpected fl::except::IInternalException

Pablo Nanez

Hi @minsoo kim. Do not try to open and run install.m, just go to the command window and execute instal, e.g., >> install. The file is too big to be opened by the editor, you just need to execute it.

minsoo kim

I tried to install it (by install.m) but matlab always shows "out of memory".

Pablo Nanez

Hi @Tadashi, great question! yes, it is possible. It would be possible to craft such system in both the lite and the Simulink interfaces, but I think is more straightforward to do it in simulink. In the mean time, you can modify the example: Hybrid Equations Toolboox>>CPS examples>>Continuous Plant Example, and modify it so that the input "u" of the hybrid system "plant" is e. We will implement a more detailed example in the next release of the simulator. Thanks for the suggestion!


It is possible to simulate hybrid systems with measurement noise? That is,
a hybrid system with data (C,f,D,g) given by

x' = f(x+e), x+e ∈ C,
x⁺ = g(x+e), x+e ∈ D,

where e: dom e → Rⁿ is a measurement noise?

If so, could an example be included in the documentation?
Thanks! :)


Pablo Nanez

A new version of the simulator is available!
The main new features are:
1) Compatibility issues with matlab 2014-2017a are now solved
2) Instructions file updated
3) New examples and html files
4) Now is possible to solve DAE equations as a flow maps
5) Now flow maps and jump maps can access the hybrid time domain, e.g., f(x,t,j)

Deejay Stander

Pablo Nanez

A new version of the simulator is available!

The main new features of this new version are:

1) New zero events code in the lite HyEQ simulator
2) Instructions file updated
3) New help html files
4) Smaller installation file
5) Cyber Physical Systems CPS blocks in the simulink library (interconnected systems)
6) CPS examples
7) Problems in installation for 2014b are now solved
8) Now is possible to select which ode solver the lite HyEQsolver is going to use
9) New plot functions for pre and post 2014b plot behaviour

Pablo Ñañez

The main changes from 2.0 to 2.01 are:
1) Added two new plotting functions plotHarcColor and plotHarcColor3D
2) All functions have now the standard head (H1) help line (which is required to search functions such as "lookfor", e.g., >> lookfor HyEQ, or >> lookfor hybrid)
3) Functions plotC and plotD were removed (none of examples uses those functions)
4) New help environment for all functions were created (with examples inclued), e.g.,
>> help HyEQ_Toolbox_V201
>> help HyEQsolver
>> help plotflows
>> help plotHarc
>> help plotHarcColor
>> help plotHarcColor3D
>> help plotHybridArc
>> help plotjumps
>> helpwin HyEQ_Toolbox_V2_01
5) Some of the postprocessig files in the examples (simulink) were edited to include the new plotting functions.


what's new from version 2.00 to 2.01?

Pablo Ñañez

This blog contains guidelines, hints, and examples for the use (and misuse) of the Hybrid Equations (HyEQ) Toolbox

Pedro Casau


Very useful. Nice!




A new version of the simulator is available!
The main new features are:
1) Compatibility issues with matlab 2014-2016 are now solved
2) Instructions file updated
3) New examples and html files
4) Now is possible to solve DAE equations as a flow maps

A new version of the simulator is available!
The main new features are:
1) Compatibility issues with matlab 2014-2016 are now solved
2) Instructions file updated
3) New examples and html files
4) Now is possible to solve DAE equations as flow maps

Change log:
-new zero events in lite version
-new help files
-smaller insttallation file
-new CPS blocks
-new plotting functions, now compatible with pre and post 2014a plot behaviour
-update of the simulink library
-CPS examples

Instruction file for installation were updated.
Install problems in iMac's OS X 10.9.5 are solved.

1)Added two new plotting functions plotHarcColor and plotHarcColor3D
2)All functions have now the standard head (H1) help line
3)Functions plotC and plotD were removed
4)New help environment for all functions were created (with examples inclued)

Help files and instructions updated.

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: LibHybrid for System Identification Toolbox