We would like to import a simple Simulink model. This model is located in the BlockImporter data directory. The following command will return the location of this data directory.
| (4.1) |
This directory contains the model file (example.mdl) and an initialization script (example_init.m). The initialization script contains the definition of two parameters, a1 and a2, that must be defined before the model can be executed.
To import the model, we call the Import function, and give it the name of the model that we want to import. In our case the model is called example. Optionally, we also pass in the name of the initialization script, and the directory where the model is located. The function will return a data structure with the imported equations, and we will assign it to the variable sys.
The import command makes a copy of the model and calls it temp_example, and adds numerical IDs to all the blocks in the model. These IDs correspond to the variable names in the extracted equations.
The variable sys contains the representation of the model, and is represented as a record data structure, which contains the following fields.
blockeqs: list of the equations extracted from the model
| (4.2) |
|
initialeqs: list of initial equations
| (4.3) |
|
statevars: list of state variables
| (4.4) |
|
inputvars: list of input variables
| (4.5) |
|
outputvars: list of output variables
| (4.6) |
|
sourceeqs: list of source equations for the input sources
| (4.7) |
|
parameters: list of constant parameters
| (4.8) |
|
notes: list of any notes generated during the import
|
procs: procedure required to implement some of the blocks (for example lookup). Note that this field is a table, rather than a list.
|
|
|
A convenient procedure, PrintSummary, displays all the fields of this data structure.
| (4.11) |