Learn the basics of how to create a model, add blocks to a model, connect blocks, and simulate a model. You also learn how to organize your model with subsystems, name parts of a model, and modify a model.
For a summary of how to connect blocks and add ports interactively, see Keyboard Shortcuts and Mouse Actions for Simulink Modeling.
On the Simulink® Start Page, choose a template or search the templates.
Model templates are starting points that you can use to apply common modeling approaches. They help you reuse settings and block configurations. Use model and project templates to ensure your designs are applying best practices and to take advantage of previous modeling solutions.
Click the title of a template to read the description.
Search for templates by entering text in the search box. You can enter flexible search options, including OR, AND, NOT, use wildcards, do a fuzzy search (~), and more. Use the Lucene search engine query parser syntax.
To locate templates that are not on the MATLAB search path, click Open. Model templates have the
After selecting the template you want, click Create Model.
To use a template without reading the description, click the template image. Alternatively, press Ctrl+N to use your default template.
A new model using the template settings and contents opens in the Simulink Editor.
If the built-in templates do not meet your needs, try searching on the Examples tab or creating your own templates. See Create Template from Model. On the Examples tab, enter search terms to search the titles and descriptions of the examples, or open examples on the web by clicking View All next to a product name.
You can specify a model template to use for all new models.
Create a model with the configuration settings and blocks you want, then export the model to a template. See Create Template from Model.
To reuse these settings in every new model, make the new template your default
model template by using the Simulink Start Page or the
On the Start Page, click the title of a template to expand the description, then click the down arrow next to Create Model and select Set As Default.
After you set a default model template, every new model uses that template, for example,
when you press Ctrl+N, when you use new model buttons, or
when you use
new_system. In the Simulink Editor, your default template appears at the top of the list when, on the
Simulation tab, you select
The default template shows a tick mark on the Start Page.
Opening a model loads the model into memory and displays it in the Simulink Editor. Use any of these techniques:
On the MATLAB Toolstrip, on the Home tab, click Simulink. On the Simulink Start Page, select a recent model or project from the list, or click Open.
In the Simulink Toolstrip, on the Simulation tab, select Open and click Recent Files to open recent files or Open to search for a model.
At the MATLAB Command Window, enter the name of the model without a file extension,
vdp. The model must be in the current folder or on the
MATLAB search path.
In the Simulink Library Browser, click the Open button .
Open the model using the Current Folder browser or your operating system file browser.
To open a model created in a later version of Simulink software in an earlier version, first export the model to the earlier version. See Export Model to Previous Simulink Version.
Set favorites to easily find your favorite models and projects on the Simulink Start Page.
In the Recent list, you can add files to favorites. The Favorites list then appears above recent files on the Start Page, so you can easily reopen your favorite models and projects.
To edit or clear the list of recent files on the Start Page, right-click a recent file and click Remove from List or Clear List.
Simulink.history.clear to clear the Simulink history programmatically.
As you build models, you sometimes define variables for a model. For example, suppose
that you have a model that contains a Gain block. You can specify the variable
K as the gain rather than setting the value on the block. When you use
this approach, you must define the variable
K for the model to simulate.
You can use a model callback to load variables when you open a model.
In a model that uses the Gain block, set the block Gain value
Define the variable in a MATLAB script. In MATLAB, select New > Script. In the script, enter your variable definitions:
Save the script as
In the model, open the Property Inspector. On the Modeling tab, under Design, click Property Inspector.
At the top level of a model, click an empty space in the Simulink Editor canvas to ensure nothing is selected.
On the Properties tab, in the Callbacks
PreLoadFcn, then enter
Save the model.
The next time that you open the model, the
loads the variables into the MATLAB workspace.
You can also use the Model Properties dialog box instead of the Property Inspector. On the Modeling tab, click Model Settings > Model Properties.
To learn about callbacks, see Callbacks for Customized Model Behavior. To define a callback for loading variables programmatically, see Programmatically Load Variables When Opening a Model.
If you open an MDL file created in a release prior to R2021b in a MATLAB session that uses different encoding, you receive a warning. For example,
suppose you create an MDL file in a MATLAB session configured for
Shift_JIS and open it in a session
windows-1252. The warning message displays the encoding of
the current session and the encoding used to create the model. Starting in R2021b, MDL
files, similar to SLX files, can store characters from any encoding. Resave your model files
as MDL or SLX files.
New models have the
.slx extension by default. Models created before
R2012b have the extension
.mdl. You can edit models with either the
.mdl extension, depending on when they were
created and whether you converted them. See Save Models in the SLX File Format.
.mdlp extensions denote protected models
that you cannot open or edit. See Reference Protected Models from Third Parties. Model templates have the
Simulink libraries and subsystems can also use the
To learn more, see Choose Among Types of Model Components.