Simulink Editor

Create models and set model properties

Description

The Simulink® Editor allows you to create and configure system models.

The Simulink Editor is a tool for building models. In addition to providing standard methods for working with diagrams in a vector graphics editor, the editor provides shortcuts that help you to add and connect blocks. The Simulink Editor also gives you access to the tools you need for technical operations such as importing data, simulating your model, and analyzing model performance.

Interactive Model Building

When you build a model in the Simulink Editor, you use common techniques for working with graphics objects. Some of these actions include:

  • Selecting using click, shift-click, and dragging

  • Resizing objects using handles and moving objects by dragging

  • Cutting, copying, and pasting

  • Undoing and redoing up to 101 operations

    Note

    After you undo or redo block parameter changes, a visual cue appears that shows the current values of the affected parameters. Some parameter changes are not affected by the undo or redo commands. After you undo or redo changes to block parameters, use the cue to see the parameters affected.

    A small subset of parameters can not be undone. Changing these parameters clears the undo history when you make the change in the Property Inspector or in the block dialog box.

You can also zoom and scroll the editing area. On the Modeling tab, select Environment > Zoom, and select the zoom or view you want to use. If you are using a supported touch display platform, you can pinch to zoom and swipe to scroll. The supported touch display devices include Microsoft® Windows® platforms with a Windows 7 certified or Windows 8 certified touch display and Macintosh platforms with an Apple Magic Trackpad.

The editor supports additional shortcuts for scrolling that are unique to Simulink. Shortcuts and other interactive model building techniques are summarized in Keyboard Shortcuts and Mouse Actions for Simulink Modeling. For a tutorial, see Build and Edit a Model Interactively.

Model Design Error Detection

The Simulink Editor can provide you with visual cues for some model design issues. In the model editor, highlighted blocks alert you to issues. To see a description of the issue, hover over a highlighted block and click the error or warning symbol.

Edit time error

Similar to the Diagnostic Viewer, if an error or warning has a predefined fix, the notification dialog box lists actions and may include a Fix button to apply these changes.

Simulink can detect block errors and warnings, such as:

  • Goto and From block mismatches.

  • Duplicate data store blocks. The value of the Duplicate data store names parameter determines determines whether to display a warning or an error symbol.

The Errors and Warnings option is enabled by default. To turn off this option, in the Debug tab, select Diagnostics > Edit-Time Errors & Warnings.

Exploring the Model Hierarchy

Use the Model Browser to navigate a model hierarchy using a tree structure. The browser helps you to understand the organization of your model and explore systems within systems.

To display the Model Browser, in the Simulink Editor, in the Modeling tab, select Environment > Model Browser. You can toggle the Model Browser display by clicking the Hide/Show Model Browser control Hide/Show Model Browser.

Model Browser

In the Model Browser, you can specify whether to display blocks that are linked to a library or to masked subsystems. Click Model Browser icon and select Library Links or Systems with Mask Parameters. For information on these types of blocks, see Linked Blocks and Masking Fundamentals.

Search for Model Elements Using Find

You can search in Simulink models on the Modeling tabby clicking Find . Use Find to locate, navigate to, and select any element that matches the search string that you enter. The search can match the string anywhere in the element, such as in the name or in parameter values. You can customize the search to look only in certain types of elements or when specific parameters are set a certain way.

Default Search Search Options
In the current systemSpecify to search the current system and all systems below it in the model hierarchy.
In all model elements, including all types of Simulink and Stateflow® objectsNarrow your search to include only the elements you are interested in, such as blocks, annotations, or signals.
In parametersSpecify to omit parameter values from the search.
Case-insensitive, partial matchesSearch for an exact match and use regular expressions.
In referenced models but not in linked blocks or masked systemsYou can turn each of these options off and on.

Open the Simulink Editor

  • Create a model. On the MATLAB® Home tab, click Simulink and choose a model template.

    Alternatively, if you already have the Library Browser open, click the New Model button New Model.

  • Open an existing model. To open recent models, on the MATLAB Home tab, click Simulink.

    Alternatively, if you know the name of the model you want to open, enter the name at the MATLAB command prompt, such as vdp.

Tip

The first model that you open in a MATLAB session takes longer to open than subsequent models. By default, MATLAB does not start Simulink until you open the first model to reduce MATLAB startup time and avoid unnecessary system memory use.

To speed up opening the first model, you can configure MATLAB startup to also start Simulink. For more information on how to do that and also start Simulink without opening models or the Library Browser, see the start_simulink reference page.

Examples

expand all

Search in the top level of the model sldemo_fuelsys for any model element that contains the number 2.

Open the Property Inspector to see properties and parameters. In the Modeling tab, under Design, click Property Inspector.

  1. Open the model sldemo_fuelsys.

  2. On the Modeling tab, click Find.

  3. In the search box, enter 2 and press Enter.

    Nine model elements appear highlighted. The first element found, the copyright annotation, has a stronger highlight to show that it is the current match.

  4. To move to the next element, click the down arrowSmall blue arrow to the right of the search bar. In this example, the current selection highlight moves to a Constant block. The block name does not appear in the model. Look in the Property Inspector to see the block name, Constant2.

  5. Use the up and down arrows to move through the rest of the elements found.

You can narrow your search by specifying search criteria.

  1. On the Modeling tab, click Find.

  2. Enter the search string. Alternatively, you can add the search string later.

  3. Click View Details.

    View Details

  4. Click the Configure advanced search settings button Configure advanced search settings.

  5. In the Advanced Search Settings dialog box, for each criterion you want to set, click the Add property and value button Add property and value. Select the property and enter the value for each criterion.

  6. Set any other advanced search settings, and then click OK.

  7. If you entered a search string, the search executes. Alternatively, you can enter the search string after you specify the criteria, or enter an asterisk (*) to search for any model element that matches the advanced criteria.

    Tip

    You can cancel a search and view partial search results. In the Finder interface, click the Stop Search button.

    Stop Search

Using the search box, you can specify a property and value to search for. Enter the search string in the form Property:Value. For example, to search for all Constant value parameters whose value is throttle_sw, type Value:throttle_sw and press Enter. To search for all Constant blocks, enter BlockType:Constant. To search for text that appears in the description of the block, use the form Description:textstring.

  1. Search using the programmatic name of the property. To find the programmatic name, in the Property Inspector, pause on the property.

  2. Enter the full property name, case insensitive. You cannot use regular expressions or partial matches for the property name.

  3. By default, the value search is case insensitive and finds partial matches. Use the advanced search settings to make the search case sensitive,to only return exact matches, or search using regular expressions.

To search for a string that has a colon and prevent the text before the colon from being treated as a property, use one of these approaches.

Escape the colon using a backslash, for example, Earth\: a planet.

Use single or double quotes around the expression, for example, 'Earth: a planet' or "Earth: a planet".

You can specify criteria for your search and sort the results using the Finder pane. In this example, you search for all elements that contain the string fuel. You then use the Finder pane to narrow your results. You can interact with search results while the search runs. However, you can sort the results only after the search is complete.

Tip

Use the model browser with the Finder interface to select the starting point for your search.

  1. Open the model sldemo_fuelsys.

  2. On the Modeling tab, click Find. Next to the search box, click View Details.

    View Details

  3. To expand the scope of the search, in the Finder pane, click the Click to search in current system and below button Click to search in current system and below.

  4. Search for any elements that include the string fuel. In the search box, enter fuel and press Enter.

    The model has many elements with fuel in the name or in a parameter or property value, including blocks, annotations, signals (data), and Stateflow charts.

    Use the Finder pane to make your results more meaningful. For example, you can sort the headers by clicking on them, or double-click an item in the list to go to and select the element in the model. Click an item in the list to make it the current match in the model, if it is displayed.

  5. When a search returns too many results, use the advanced search settings. Next to the search box, click the Configure advanced search settings button Configure advanced search settings.

  6. Search only for blocks. In the Advanced Search Settings dialog box, under Object Type, clear the Stateflow check box. Expand the Simulink list and clear the Annotations and Signals check boxes.

  7. Narrow the search further to look only in blocks whose description contains the word input. Under Property : Value, from the property list, select BlockDescription. In the value box, enter input, and then click the Add property and value button Add property and value. Click OK.

  8. Searching returns fewer blocks. You can add more property values to narrow the search further. For example, you can specify the type of blocks to search in. Open the Advanced Search Settings dialog box. Under Property : Value, add another property-value pair. Set the property to BlockType and the value to MultiPortSwitch. Click the Add property and value button and click OK.

    One block appears in the list.

  9. Clear the advanced search criteria. Click the arrow next to the Configure advanced search settings button and select Clear advanced settings.

Related Examples

Parameters

To support common user workflow tasks, tabs called Simulation, Debug, Modeling, Format, and Apps provide functionality corresponding to each task.

The Apps tab provides a gallery of applications from the Simulink family of products. Apps may open a new contextual tab, a separate window, or they may be a shortcut to the configuration parameters.

When you select a model component, a contextual tab displays tools to assist you in a step. For example, when you select a Subsystem block, the Subsystem tab appears. If you select a Stateflow® chart, the State Chart tab appears. When the block or chart is no longer selected, the contextual tabs disappear.

The quick access toolbar contains frequently used options such as save, undo, and redo.

After opening a gallery, you can mark buttons as favorites. Buttons that are favorites appear at the top of the gallery for quicker access.

Commands also appear on context menus. Context menus appear when you right-click a model element or a blank area of the editor. For example, if you right-click a block,the menus display the commands relevant for working on blocks, such as clipboard and alignment operations. Some commands appear only on a context menu.

When you open the Property Inspector (on the Modeling tab, under Design), the Property Inspector pane opens. You can drag the Property Inspector from the default location and dock it in another location in the editor. You can collapse the Property Inspector interface by clicking the pushpin. The figure shows a block selected with the Property Inspector displayed.

Property Inspector

The Property Inspector is useful when you set parameters and properties as you work. It can stay open and available for setting values for the current selection. Values take effect when you set them. This workflow simplifies your interaction with the interface.

You can alternatively open a dialog box for a selected model element by right-clicking and selecting an item such as Properties, or for blocks, Block Parameters. Double-clicking a block generally opens a block dialog box. (Use one of the menu commands on Subsystem and Model blocks.)

The Property Inspector and dialog boxes operate on a single selection. The main difference is that the Property Inspector updates with each selection and the dialog box shows settings for only the element you opened it from. For this reason, the dialog box is useful if:

  • You are moving through the model hierarchy and want to see or set element parameters or properties as you navigate the model.

  • You want to compare the parameters or properties of similar elements.

  • The settings are advanced and appear only in the dialog box.

Use Model Data Editor (on the Modeling tab, click Model Data Editor), to configure multiple signals, states, and algorithmic parameters at once. You can set only certain parameters and properties such as data types, initial values, and physical units. To work with one model element at a time, open the Property Inspector. To perform batch operations, open the Model Data Editor.

For more information about setting block properties and parameters, see Signal Properties. To learn to use the Model Data Editor, see Configure Data Properties by Using the Model Data Editor.

The palette along the left side of the editor provides shortcuts to commands you can use to modify the model appearance and navigate the model. For example, the palette includes a shortcut for adding annotations and other visuals, like boxed-in areas for labeling the model. It also provides a zoom button for zooming on a particular part of the model.

The Hide/Show Explorer Bar button in the upper left corner of the editor window displays a bar that shows where you are in the model hierarchy.

The Hide/Show Model Browser button displays the Model Browser pane. You can use this pane to view and navigate a hierarchical view of the model.

The control in the lower-right corner opens additional views of the model. One such view is the interface view, which helps you to trace model interfaces. Click the control to see these views.

A badge in the lower-left corner indicates that a model has external data sources, such as a data dictionary, or that there is data in the model workspace. Click the badge, then use the menu to navigate to these data sources.

  • To open the Model Explorer with the Model Workspace node selected, click the Model Workspace link.

  • To open the Model Explorer with the External Data node for the model selected, click the External Data link.

  • To add or change a linked data dictionary, click the gear icon to open the External Data tab of the Model Properties dialog box.

Programmatic Use

expand all

simulink opens the Simulink Start Page. Select a model or template to open the Simulink Editor.

Introduced before R2006a