Open access peer-reviewed chapter

Simulation of Piecewise Hybrid Dynamical Systems in Matlab

By Fatima El Guezar and Hassane Bouzahir

Submitted: December 6th 2011Reviewed: May 7th 2012Published: September 26th 2012

DOI: 10.5772/48570

Downloaded: 4102

1. Introduction

A hybrid dynamical system is a system containing on the same time continuous state variables and event variables in interaction. We find hybrid systems in different fields. We cite robotic systems, chemical systems controlled by vans and pumps, biological systems (growth and division) and nonlinear electronics systems.

Because of interaction between continuous and discrete aspects, the behavior of hybrid systems can be seen as extremely complex. However, this behavior becomes relatively simple for piece-wise affine hybrid dynamical systems that can, in contrast, generate bifurcation and chaos. There are many examples such as power electronics DC-DC converters.

The common power electronics DC-DC converters are the buck converter and the boost converter. They are switching systems with time variant structure [9].

DC-DC converters are widely used in industrial, commercial, residential and aerospace environments. These circuits are typically controlled by PWM (Piece Wise Modulation) or other similar techniques to regulate the tension and the current given to the charges. The controller decides to pass from one configuration to another by considering that transitions occur cyclically or in discrete time. In order to make the analysis possible, most of mathematical treatments use some techniques that are based on averaging or discretization. Averaging can mean to wrong conclusions on operation of a system. Discrete models do not give any information on the state of the system between the sampled instants. In addition, they are difficult to obtain. In fact, in most cases, a pure analytic study is not possible. Another possible approach to analyze these converters can be done via some models of hybrid dynamical systems. DC-DC converters are particularly good candidates for this type of analysis because of their natural hybrid structure. The nature of commutations of these systems makes them strongly nonlinear. They present specific complex phenomena such as fractals structures of bifurcation and chaos.

The study of nonlinear dynamics of DC-DC converters started in 1984 by works of Brockett and Wood [4]. Since then, chaos and nonlinear dynamics in power electronics circuits have attracted different research groups around the world. Different nonlinear phenomena have been observed such as routes to chaos following the period doubling cascade [16], [5], [19], [20] and [23] or quasi-periodic phenomena [6], [7] and [8], besides border collision bifurcations [23] and [2].

Switched circuits behavior is mostly simulated by pure numerical methods where precision step is increased when the system is near a switching condition. Those numerical tools are widely used mainly because of their ease-of-use and their ability to simulate a wide range of circuits including nonlinear, time–variant, and non–autonomous systems.

Even if those simulators can reach the desired relative precision for a continuous trajectory, they can miss a switching condition and then diverge drastically from the trajectory as in figure 1. This could be annoying when one is interested by border collision bifurcations, or when local behavior is needed with a good accuracy. In those applications, an alternative is to write down analytical, or semi–analytical, trajectories and switching conditions to obtain a recurrence which is very accurate and fast to run. Building and adapting such ad’hocsimulators represent a lot of efforts and a risk of mistakes.

Generic and accurate simulators can be proposed if we are restricted to a certain class of systems. A simulation tool with no loss of events is proposed in [14] and [15] for PWAHSs defined on polytopes (finite regions that are bounded by hyperplanes). This class of PWA differential systems has been widely studied as a standard technique to approximate a range of nonlinear systems.

But closed polytopic partition of the state space does not allow simulation of most switching circuits where switching frontiers are mostly single affine constraints or time–dependent periodical events.

This chapter follows our previous study in [13], [12] and [11].

We focus on planar PWAHSs with such simple switching conditions which can model a family of switched planar circuits: bang–bang regulators, the Boost converter, the Charge-Pump Phase Locked Loop (CP-PLL),...

This class of systems has analytical trajectories that help to build fast algorithms with no loss of events. We propose a semi-analytical solver for hybrid systems which provides:

  • A pure numerical method when the system is nonlinear or non-planar;

  • A pure analytic method when all continuous parts of the system and switching conditions can be solved symbolically. This can be the case for the boost converter [3], [21], the second order charge-pump phase locked loop [17], [22].

  • A mixed method using analytical trajectories and numerical computation of the switching instant when those solutions are transcendent. This has been used for the third order CP-PLL [17]. It can also be the case for the Buck converter [10], [21],...

This chapter is organized as follows. Section 2 contains our main results. We describe the problem to be deal with, we introduce a general algorithm to solve planar HSs, we present the algorithm that detects events’ occurrence and devote a subsection to our approach efficiency. Section 3 Illustrates the current-mode controlled Boost converter example. Finally, a conclusion is stated in Section 4.

Figure 1.

Numerical simulation versus semi–analytical simulation.


2. Main results

2.1. A HS(X,E,t): general definition

A general definition of HSs is presented here. This type of dynamical systems is characterized by the coexistence of two kinds of state vectors: continuous state vector X(t)of real values, and discrete state vector E(t)belonging to a countable discrete set.

Definition 1A continuous-time, autonomous HS is a system of the form:


=n×is called the hybrid state space. X(t)nis the continuous state vector of the HS at time instant tand E(t):={1,,N}is its discrete state. E+(t)denotes the updated discrete state right after time instantt. ϕ:describes the discrete dynamic, it is usually modeled by Petri Nets. A transition from E(t)=ito E+(t)=jis valid when the state Xreaches a switching set calledSEi,Ej. Such transitions are called state dependent events. A HS is called piece-wise affine if for eachE, F(X,E)can be defined byF(X,E)=AEX+BE,X.

Remark— For non–autonomous HSs, the function ϕcan also depend on timeϕ(X,E,t):n××. Then time dependent events can occur and validate a transition, such as periodic events.

2.2. HSs class of interest

We consider a two dimensional PWAHS (X(t)2). Fhas then the affine piece-wise form, F(.,.)is defined for each Eand X2byF(X(t),E(t))=AE(t)X+BE(t), where AE(t)2×2and BE(t)2are two matrices that depend on the discrete stateE(t). Hence, a two dimensional PWAHS is a HS that take the form:


We consider two kinds of events: state dependent events and periodic events.

The state dependent event transition SEiEjis defined by an affine state border of the formNij.X<lij. In this case an event can occur when the continuous state reaches the border of the setSEiEj={X(t)2:Nij.Xlij}.

Note that the set SEiEjis not polytopic in the sense that the domain is not the interior of a closed bounded polytope.

Remark— We consider, without loss of generality, the case where a transition occurs at time dSEiEjif and only if the state X(dSEiEj)reaches a border of the set SEiEjfrom outside. Figure 2 defines a transition with the complimentary setS¯, which allows to detect the event in both directions.

Figure 2.

Oriented polytopic state dependent transitions.

Both transitions can be met with the setB=SS¯. Periodic events are simply defined by time instantst=dEiEj, where dEiEjbelongs to the set EiEj={t:t=kT+φ,k}.Tis the period and φis the phase of such periodic events.

2.3. Event–driven simulation of PWAHSs

The simulation will compute the hybrid state from event to event. Knowing the states X(tk)andE(tk+), one can compute the trajectoryX(t>tk)=tktf(X(tk),E(tk+))dt+X(tk), assuming that the discrete state is constantE(t>tk+)=E(tk+). Then the following algorithm runs the simulation determining the date at the next event as the smallest:

Algorithm 1. Algorithm computing the hybrid state attk+1.

2.4. Event detection occurrence: description and algorithm

We consider the affine Cauchy problem in2:


where X0is the initial value. We compute the smallest strictly positive time ti*so that the trajectory of X(t)intersects the fixed border Biarriving from the part of the plan whereNi'.X<li. The function fi(t)=Ni.X(t)lidefines the guard condition for a borderBi. Thus, the problem can be formulated as follows:


If fidoes not have any strictly positive root or the last condition is not satisfied, ti*is given the infinite value.

2.4.1. Analytical trajectories

Definition 2For any square matrixAof ordernandtin, the exponential matrixetAis defined by


where Iis the identity matrix.

It is well known that the analytical trajectory X(t)of the initial value matrix differential equation (3) is given in terms of the exponential matrix and the variation of constants formula by the general integral form:


When Ais invertible, the above expression becomes linear:


The analytical expression of the exponential matrix eAttakes two forms depending on whether the eigenvalues p1and p2of the matrix Aare equal or not:



, then




, then


whereA=(a11a12a21a22), A=(a22a12a21a11)andI=(1001).

Using these expressions, we can determine the function f(t)of the problem (4) as follows:


where aiare real scalars.

Depending on the eigenvalues p1andp2, there are five cases that determine the values of the coefficients aias shown in Table 1.


Table 1.

Expressions of f(t)depending on the eigenvalues p1andp2.

Remark— Coefficients aiare real scalars that depend on the eigenvalues p1andp2, the initial point Xkand the border parameters are Niandli.

In some cases, (p1=p2=0, gray cell in Table 1) roots of f(t)can be found analytically and the problem is solved with machine precision.

In other cases, the solution can not be found with classical functions and then a numeric algorithm should be used. Using classical methods like Newton does not guaranty existence or convergence of the smallest positive root. To meet these conditions, let us use analytical roots of the derivative function f(t)expressed in Table 2.


Table 2.

Expressions of f(t)depending on the eigenvalues p1and p2

We can then compute analytically the set Lof ordered roots off(t), those roots determines monotone intervals off(t). The following algorithm is used to return the solution t*when it exists or the value if not.

Remark— When (p1,p2)*×*the set Lis infinite: when the real part of piis positive, the algorithm

Algorithm 2. Algorithm computing t*when a solution is transcendent.

will end by finding a root. In the other case, the set Lshould be reduced to its three first elements, to find a crossing point when it exists.

3. Matlab modelling

Our semi-analytical solver is composed of different main programs that define the studied affine system. First, we create the affine system given with a specifically chosen name. Then, we define the matrices AiandBi. After that, we give the switching borders with the sign of transitions and all necessary elements or we give the period if it is about a periodic event. Finally, we execute the simulation by specifying the initial state and the time of simulation.

3.1. Application: Current-mode controlled Boost converter

A current-mode controlled Boost converter in open loop consists of two parts: a converter and a switching controller. The basic circuit is given in figure 3.

This converter is a second-order circuit comprising an inductor, a capacitor, a diode, a switch and a load resistance connected in parallel with the capacitor.

The general circuit operation is driven by the switching controller. It compares the inductor current iLwith the reference current Irefand generates the on/off driving signal for the switchS. When Sis on, the current builds up in the inductor.

When the inductor current iLreaches a reference value, the switch opens and the inductor current flows through the load and the diode. The switch is again closed at the arrival of the next clock pulse from a free running clock of periodT.

The Boost converter controlled in current mode is modeled by an affine piece-wise hybrid system defined by the same sub-systems given in equation as follows:


Figure 3.

Boost converter controlled in current mode.

In the case of the Boost converter controlled in current mode, there are two types of events:

A state event defined by a fixed border of the setSE1E2:


and another periodic event defined by the datest=dEiEj, where dEiEjbelongs to the set:


where Tis the period of this periodic event. The different simulations are obtained using our planar PWA solver.

Before performing any study of the observed bifurcations in this circuit, a numerical simulation in the parametric plane is needed.

The following program calcule_balayage_mod.m is used to obtain the parametric plane:

After calculating the necessary points of the parametric plane saved in the file named dat_balais, the next program affiche_balayage.m plots the figure given in Fig.4

The figure 4 of the parametric plane allows to emphasize the parameters values for which there exists at least one attractor (fixed point, cycle of orderk, strange attractor).

Figure 5 shows a bifurcation diagram (Feigenbaum type) in the plane(Iref,iL). However, figure 6 shows the bifurcation diagram in the space plane(I,iL,vC).

To draw these two figures we use programs: calcule_figuier.m and affiche_figuier.m

In these two figures, the voltage Vinis fixed to 10V and the current Irefvaries in the interval[0.5,1.6]. We observe a period cascade doubling leading to a chaotic regime, interrupted by a border collision bifurcation at Iref=1.23A (see figure 7). In this figure, a distinction is given between the attractors of attractive cycle type of the order 1to14. Each cycle of order kis associated with one color.

For example, the blue area O1 represents the parameters’ values for which there exists an attractive fixed point (fundamental periodic regime). The red area O2 represents the existence of an attractive cycle of order2. The yellow area O4 represents the existence of an attractive cycle of order 4and so on until getting the cycles O14 of orderk=14. The black area O+ corresponds to parameters values (Iref,Vin) for which there exist cycles of order k15or other types of attractors. In this last area, a chaotic phenomenon could be observed. This bi-dimensional diagram shows some bifurcation curves. In fact, for the rectangle defined by the interval of parameter Vin[7,15]and the parameterIref[0.5,1.6], we observe an area of blue color (existence of attractive fixed point) followed by an area of red color (existence of cycle of order2), an area of yellow color (existence of cycle of order4) and another area of black color (existence of cycle of order k15or another attractor type); this succession of zones corresponds to the existence of period doubling cascade.

This representation of the parametric plane is not enough to establish a bifurcation structure of the hybrid model of the Boost converter, but it is useful for the initialization of programs to draw bifurcation curves..99 The simulation results (temporal domain and voltage-current plane (vC,iL)) are obtained using the planar PWH solver in the case of the Boost converter controlled in current mode for periods: 1T(figure 8) for Iref=0.7A, 2T(figure 9) for Iref=1A, 4T(figure 10) for Iref=1.3A and the chaotic regime (figure 11) for Iref=1.5A. For these plots we used the code below by choosing the bifurcation parameter Irefcorresponding to each period case.

Figure 4.

Parametric diagram of the Boost converter in the plane(Iref,Vin)forIref[0.5,1.6]A andVin[5,20]V.

Figure 5.

Bifurcation diagram of the Boost in the plane(Iref,iL)forIref[0.5,1.6]A andVin=10V fixed.

Figure 6.

Bifurcation diagram of the Boost in the space(Iref,iL,vc)forIref[0.5,1.6]A andVin=10V fixed.

Figure 7.

Zoom offigure 5: Border collision forIref=1.23A.

Figure 8.

Fundamental periodic regime forIref=0.7A: (a) (up) temporal waveform of the voltagevC, (down) temporal waveform of the currentiL; (b) phase plane (vC,iL).

Figure 9.

Cycle of order 2 forIref=1A:(a) (up) temporal waveform of the voltagevC, (down) temporal waveform of the currentiL; (b) phase plane (vC,iL).

Figure 10.

Cycle of order 4 forIref=1.3A: (a) (up) temporal waveform of the voltagevC, (down) temporal waveform of the currentiL; (b) phase plane (vC,iL).

Figure 11.

Chaotic regime forIref=1.5A: (a) (up) temporal waveform of the voltagevC, (down) temporal waveform of the currentiL; (b) phase plane (vC,iL).

4. Conclusion

In this chapter, we have showed an accurate and fast method to determine events’ occurrence for planar piece-wise affine hybrid systems. As a result, we have implemented our algorithm in Matlab toolbox version (free downloadable on

This toolbox has also been completed by analysis tools such as displaying the bifurcation and parametric diagrams. The algorithm takes the advantage of the analytical form that appears in the planar case. Our approach can not be extended to a higher dimension. DC-DC converters like Boost converter are known to be simple switched circuits but very rich in nonlinear dynamics. As application, we have chosen the example of Boost converter controlled in current mode.


The authors would like to thank Pascal Acco and Danièle Fournier–Prunaret for crucial discussions on the original version of our work on this subject.

© 2012 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms of the Creative Commons Attribution 3.0 License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

How to cite and reference

Link to this chapter Copy to clipboard

Cite this chapter Copy to clipboard

Fatima El Guezar and Hassane Bouzahir (September 26th 2012). Simulation of Piecewise Hybrid Dynamical Systems in Matlab, MATLAB - A Fundamental Tool for Scientific Computing and Engineering Applications - Volume 3, Vasilios N. Katsikis, IntechOpen, DOI: 10.5772/48570. Available from:

chapter statistics

4102total chapter downloads

More statistics for editors and authors

Login to your personal dashboard for more detailed statistics on your publications.

Access personal reporting

Related Content

This Book

Next chapter

Robust Control of Distributed Parameter Systems with Demonstration in Casting Technology and MATLAB/Simulink/DPS Blockset Software Support

By Cyril Belavý, Gabriel Hulkó and Karol Ondrejkovic

Related Book

First chapter

PID Control Design

By A.B. Campo

We are IntechOpen, the world's leading publisher of Open Access books. Built by scientists, for scientists. Our readership spans scientists, professors, researchers, librarians, and students, as well as business professionals. We share our knowledge and peer-reveiwed research papers with libraries, scientific and engineering societies, and also work with corporate R&D departments and government entities.

More About Us