back to top
|
Introduction
|
|
This document is intended for beginner users of BlockImporter. It gives an overview and through an example explains how to work with BlockImporter. The example illustrates how to import a system, simplify the equations, and simulate them in Maple. For details, see the help page on BlockImporter.
|
|
Setting up BlockImporter
|
|
BlockImporter requires that the following components be set up correctly.
For details, see the BlockImporter,setup help page.
|
|
Initialization
|
|
| (3.1) |
|
|
Importing a Simple System
|
|
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.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
| (4.9) |
|
procs: procedure required to implement some of the blocks (for example lookup). Note that this field is a table, rather than a list.
| (4.10) |
|
|
|
A convenient procedure, PrintSummary, displays all the fields of this data structure.
| (4.11) |
|
|
Simplifying the Model
|
|
The structure that has been imported from the model contains over 20 equations; however, many of these equations are of the trivial form . We can simplify the total number of equations with the SimplifyModel command, and store the result in the sys2 data structure, using the same internal format.
| (5.1) |
The summary of this model reveals that the simplified model contains significantly fewer equations.
| (5.2) |
|
|
Building Differential Equations and Simulating the Model
|
|
The equations that are contained in the data structure imported from Simulink are not differential equations, and therefore are not suitable to simulate the system using the dsolve command. To convert the structure to a suitable form, we use the BuildDE command, and assign the result to the variable deq.
| (6.1) |
The result is a list of objects.
equations: set of differential equations with the parameters left in the symbolic form
| (6.2) |
|
initialeqs: list of initial conditions
| (6.3) |
|
sourceeqs: list of the source equations
| (6.4) |
|
outputvars: list of output variables
| (6.5) |
|
parameters: list of parameter values
| (6.6) |
|
known: set of procedures in the differential equations
| (6.7) |
|
|
|
To simulate the model, we substitute the source equations into the differential equations, add the initial conditions, and pass the equations to the dsolve procedure, which returns a simulation procedure.
| (6.8) |
The time domain solution can be plotted.
|
|
Available Resources
|
|
The following resources are available.
•
|
BlockImporter Tour highlights the BlockImporter features and showcases a number of examples
|
|
|
Download Help Document
Was this information helpful?