Introduction to Stateflow with Applications

This chapter describes the procedure for adding Embedded MATLAB functions to Stateflow charts. It begins with an introduction to Embedded MATLAB functions using an example, followed by procedures for building a Simulink model with a Stateflow chart that calls the Embedded MATLAB function.
Figure 4.1 below shows an example of a Stateflow Chart in a Simulink model and Model Coverage for an Embedded MATLAB function inside the Stateflow Chart.
The Stateflow documentation presents an example model named intersecting_rectangles where the if statement is tested for Decision Coverage. Other statements that can be tested for Decision Coverage are switch, for, and while. However, we can create a model without these statements as illustrated with the example below.
Consider the electric circuit shown in Figure 4.2.
From electric circuit [*] theory, we know that the resonant frequency 0 is found from the relation
[ ]
or in terms of the radian frequency ? 0 from the relation
Often, we want to adjust the variable capacitor indicated with an arrow in Figure 4.2, to produce a desired resonant frequency. In practice, the value of the inductor is held fixed and the value of the capacitor is varied.
For our model, we want to set the value of the capacitor so that the radian resonant...