Exercise 3

1 Question

What is a hybrid model?


1.1

A hybrid model is a model with mixed continuous and discrete parts.


2 Question

What do hybrid models have to do with if- and when-equations?


2.1

Well, the thing is that one can use both constructs for hybrid models. The if-equations may contain continuous-time expressions and when-equations may only contain discrete-time expressions.


3 Question

But why is that?


3.1

The if-equations or if-expressions are used for conditional models with different behavior in different operating regions. Consider for example the code below (you're not able to run it).

The if-equation in the ideal Diode Example below specifies different equations for the variable v in two different operating regions: the v = s in the region s = 0.




The when-equations, on the other hand, are used to express instantaneous equations that are only
valid (become active) at events, e.g. at discontinuities or when certain conditions become true. Discrete-time expressions only become active at event instants.

This model has only one kind of event, the sampling event. We use the built-in function
sample in the when-condition sample(0, T) to periodically generate the sampling events with a period time T. (Read more about sampling events in chapter 13.)