Main Content

Simulink Preferences

Settings for Simulink Editor and model files

Description

Use Simulink® Preferences to specify Simulink editing environment options and default behaviors. Your settings affect the behavior of all Simulink models, including those currently open and all subsequent models. Your preference settings are preserved for the next time you use the software.

Use the Simulink Preferences window to:

  • Set preferences for generated file folders

  • Set background colors for print or export

  • Set model block, callback, and sample time legend display

  • Configure Simulink Editor

  • Set preferences for file change, autosave, version notifications, and other behaviors relating to model files

Note

To remove items that appear in the Simulink Toolstrip and context menus, see Disable Simulink Toolstrip and Context Menu Actions.

Simulink Preferences

Open the Simulink Preferences

  • Simulink Toolstrip: On the Modeling tab, in the Evaluate and Manage section, select Environment > Simulink Preferences.

  • MATLAB® Command Window: Enter slprivate('showprefs').

Examples

expand all

Callbacks are commands you can define that execute in response to a specific modeling action, for example, opening a model or stopping a simulation. When you enable Show Callback Tracing in Simulink Preferences, the MATLAB Command Window displays callbacks as they are invoked. For more information on callbacks, see Customize Model Behavior with Callbacks.

Display the callback that runs when you open the Double Spring Mass System model. The example model represents a double spring-mass-damper system with a periodically varying forcing function.

  1. Open Simulink Preferences. In the Simulink Toolstrip of any open model window, on the Modeling tab, in the Evaluate and Manage section, select Environment > Simulink Preferences.

  2. In Simulink Preferences, on the General Pane, select Show Callback Tracing.

  3. Click Apply.

  4. If the Double Spring Mass System model is open, close it.

  5. Open the Double Spring Mass System model.

    openExample('simulink_general/sldemo_dblcart1Example')
    Evaluating callback 'PostLoadFcn' for sldemo_dblcart1
    Callback: crtanim2([],[],[],0,1);

    The invoked callback is a PostLoadFcn callback that runs the crtanim2 function.

  6. You can use the information about the type of callback to find where the commands that it executes are specified. To do so for this example, right-click the canvas and select Model Properties.

  7. On the Callbacks tab, select PostLoadFcn*. The right pane of the Model Properties dialog box shows the callback that ran when the model opened.

    The image shows the Model Properties dialog box for sldemo_dblcart1 with the Callbacks tab open. In the tree on the left pane, PostLoadFcn* is selected. The right pane displays the command crtanim2([],[],[],0,1);.

By default, when you specify a block parameter as a variable, the text box in the Block Parameters dialog box where you specify the parameter displays the value of the variable. You can use the display to obtain the value that a variable has at a certain point during simulation, and to debug your model.

You can use Simulink Preferences to turn the display off, for example when you are demonstrating a model and the value of the variable is confidential, or when the display gives away the answer to a problem that your students or trainees are supposed to solve.

In this example, view and then turn off the display of the heater air temperature in the Thermal Model of a House model. The heater air temperature is specified as the variable THeater in the Heater subsystem.

  1. To open the model, use this command.

    openExample('simulink_general/sldemo_househeatExample')
  2. To open the Heater subsystem, double-click the Subsystem block.

  3. To see the value of the THeater variable, double-click the Heater Air Temperature block. The Block Parameters dialog box opens.

  4. The Constant value text box displays the name of the variable on the left and the value of the variable on the right.

    The image shows the top half of the Block Parameters dialog box for the "Heater Air Temperature" block. There is one text box, with the label "Constant value" above it. The text box displays the name of the THeater parameter on the left, and the value of the parameter, 50, on the right.

  5. Close the Block Parameters dialog box.

  6. Open Simulink Preferences. In the Simulink Toolstrip, on the Modeling tab, in the Evaluate and Manage section, select Environment > Simulink Preferences.

  7. In Simulink Preferences, on the Editor Pane, turn off Display value of parameter when specified using variables.

  8. Click Apply.

  9. In the model, double-click the Heater Air Temperature block. The Block Parameters dialog box opens. The Constant value text box no longer displays a value.

    The image shows the top half of the Block Parameters dialog box for the "Heater Air Temperature" block. There is one text box, with the label "Constant value" above it. The text box displays the name of the THeater parameter on the left, but does not display the value of the parameter.

Parameters

expand all

General Pane

Simulink cache files contain build artifacts that can speed up simulation and code generation. For more information, see Share Simulink Cache Files for Faster Simulation and Manage Build Process Folders (Simulink Coder).

The cache files are stored in the simulation cache folder. The simulation cache folder is a root folder.

Specify the path to the simulation cache folder as a character vector.

You can specify an absolute or relative path to the folder. For example:

  • 'C:\Work\mymodelsimcache' and '/mywork/mymodelsimcache' specify absolute paths.

  • 'mymodelsimcache' is a path relative to the current working folder (pwd). The software converts a relative path to an absolute path when you set the preference. For example, if pwd is '/mywork', the result is '/mywork/mymodelsimcache'.

  • '../test/mymodelsimcache' is a path relative to 'pwd'. If 'pwd' is '/mywork', the result is '/test/mymodelsimcache'.

Example: 'C:\Work\mymodelsimcache'

Programmatic Use

Parameter: CacheFolder
Type: character vector
Default:'pwd'

The Simulink Coder™ build process uses system target files to generate production code from a Simulink model. For more information, see Manage Build Process Folders (Simulink Coder).

The production code is stored in the code generation folder. The code generation folder is a root folder.

Specify the path to the code generation folder as a character vector.

You can specify an absolute or relative path to the folder. For example:

  • 'C:\Work\mymodelgencode' and '/mywork/mymodelgencode' specify absolute paths.

  • 'mymodelgencode' is a path relative to the current working folder (pwd). The software converts a relative path to an absolute path when you set the preference. For example, if pwd is '/mywork', the result is '/mywork/mymodelgencode'.

  • '../test/mymodelgencode' is a path relative to 'pwd'. If 'pwd' is '/mywork', the result is '/test/mymodelgencode'.

Example: 'C:\Work\mymodelgencode'

Programmatic Use

Parameter: CodeGenFolder
Type: character vector
Default:'pwd'

The Simulink Coder build process uses system target files to generate production code from a Simulink model. For more information, see Manage Build Process Folders (Simulink Coder).

The production code is stored in the code generation folder. The code generation folder is a root folder.

Select the structure of the code generation folder.

  • Model specific — Store the code in folders named after the model.

  • Target environment subfolder — Store the code in folders named after the target environment for which the model was configured.

Programmatic Use

Parameter: CodeGenFolderStructure
Values:'ModelSpecific'|'TargetEnvironmentSubfolder'
Default:'ModelSpecific'

Specify whether the color of the model canvas is white when printed or matches the color of the digital model. For more information on printing models, see Print Model Diagrams.

Programmatic Use

Parameter: PrintBackgroundColorMode
Values: 'White' | 'MatchCanvas'
Default: 'White'

Specify whether the color of the model canvas when exported to a different file format matches the color of the digital model, is white, or is transparent. For example, you can export models to the .png format with a transparent background. For more information on exporting a model to a different file format, see Print Models to Image File Formats.

  • Match Canvas Color — Match the canvas color of the model.

  • White — Use a white canvas.

  • Transparent — Use a transparent canvas so that whatever is behind the canvas is visible.

Programmatic Use

Parameter: ExportBackgroundColorMode
Values: 'MatchCanvas' | 'White' | 'Transparent'
Default:'MatchCanvas'

Specify whether the color of the model canvas when exported to a different application matches the color of the digital model, is white, or is transparent. For more information on exporting a model to a different application, see Copy Diagrams as Images.

  • Match Canvas Color — Match the canvas color of the model.

  • White — Use a white canvas.

  • Transparent — Use a transparent canvas, so that whatever is behind the canvas image shows through.

Programmatic Use

Parameter: ClipboardBackgroundColorMode
Values: 'MatchCanvas' | 'White' | 'Transparent'
Default:'MatchCanvas'

This Simulink Online preference lets you specify the keyboard layout that you are using.

The software attempts to automatically detect the keyboard layout. When the software is unable to automatically detect the keyboard layout, the software uses English (US) as the default keyboard layout.

The available keyboard layouts include:

  • Afghani

  • Albanian

  • Amharic

  • Arabic

  • Arabic (Morocco)

  • Arabic (Syria)

  • Armenian

  • Azerbaijani

  • Bambara

  • Belarusian

  • Belgian

  • Berber (Algeria, Latin characters)

  • Bosnian

  • Braille

  • Bulgarian

  • Burmese

  • Chinese

  • Croatian

  • Czech

  • Danish

  • Dhivehi

  • Dutch

  • Dzongkha

  • English (Australian)

  • English (Cameroon)

  • English (Ghana)

  • English (Nigeria)

  • English (South Africa)

  • English (UK)

  • English (US)

  • Esperanto

  • Estonian

  • Faroese

  • Filipino

  • Finnish

  • French

  • French (Canada)

  • French (Democratic Republic of the Congo)

  • French (Guinea)

  • French (Togo)

  • Georgian

  • German

  • German (Austria)

  • German (Switzerland)

  • Greek

  • Hebrew

  • Hungarian

  • Icelandic

  • Indian

  • Indonesian (Jawi)

  • Iraqi

  • Irish

  • Italian

  • Japanese

  • Kazakh

  • Khmer (Cambodia)

  • Korean

  • Kyrgyz

  • Lao

  • Latvian

  • Lithuanian

  • Macedonian

  • Malay (Jawi)

  • Maltese

  • Maori

  • Moldavian

  • Mongolian

  • Montenegrin

  • Nepali

  • Norwegian

  • Persian

  • Polish

  • Portuguese

  • Portuguese (Brazil)

  • Romanian

  • Russian

  • Serbian

  • Sinhala (phonetic)

  • Slovak

  • Slovenian

  • Spanish

  • Spanish (Latin American)

  • Swahili (Kenya)

  • Swahili (Tanzania)

  • Swedish

  • Taiwanese

  • Tajik

  • Thai

  • Tswana

  • Turkish

  • Turkmen

  • Ukrainian

  • Urdu (Pakistan)

  • Uzbek

  • Vietnamese

  • Wolof

This Simulink Online preference lets you select the keyboard layout option that you are using. The available keyboard layout options depend on what you specify for the Keyboard preference.

For example, when Keyboard is set to English (US), the available keyboard layout options include:

  • Default (default)

  • Cherokee

  • English (US, with euro on 5)

  • English (US, international with dead keys)

  • English (US, alternative international)

  • English (Colemak)

  • English (Dvorak)

  • English (Dvorak, international with dead keys)

  • English (Dvorak alternative international no dead keys)

  • English (left handed Dvorak)

  • English (right handed Dvorak)

  • English (classic Dvorak)

  • English (Programmer Dvorak)

  • Russian (US, phonetic)

  • English (Macintosh)

  • English (international AltGr dead keys)

  • English (the divide/multiply keys toggle the layout)

  • Serbo-Croatian (US)

  • English (Workman)

  • English (Workman, international with dead keys)

Specify whether to display the model callbacks that Simulink invokes when simulating a model. Enabling Show callback tracing displays the callbacks in the MATLAB Command Window as they are invoked. For an example, see Show Callback Tracing for Double Mass-Spring System.

Programmatic Use

Parameter: CallbackTracing
Values:'off'|'on'
Default:'off'

Specify whether to display the sample time legend whenever you change the sample time display. To change the display, in the Simulink Toolstrip, on the Debug tab, in the Diagnostics section, click Information Overlays. In the Sample Time section, select Colors, Text, or both. For more information on the sample time legend, see View Sample Time Information.

Programmatic Use

Parameter: OpenLegendWhenChangingSampleTimeDisplay
Values: 'on' | 'off'
Default: 'on'
Editor Pane

Option to view diagrams in the Simulink Editor with the visual theme from before R2012b. To use the visual theme from before R2012b, set Use classic diagram theme to on. To use the visual theme introduced in R2012b, set Use classic diagram theme to off.

Note

Content preview does not display when Use classic diagram theme is enabled.

Programmatic Use

To programmatically specify whether to use the visual theme introduced in R2012b in the editor, set the EditorModernTheme parameter. To use the visual theme from before R2012b, set EditorModernTheme to 'off'. To use the visual theme introduced in R2012b, set EditorModernTheme to 'on'.

Parameter: EditorModernTheme
Values: 'on' | 'off'
Default: 'on'

Change the default display for signal lines that cross.

  • Tunnel — Causes straight signal lines that cross each other but are not connected to display a slight gap before and after the vertical line where it intersects the horizontal line.

  • Line Hop — Shows a bend where the vertical line intersects the horizontal line. The software adjusts the side the bend appears on to avoid overlapping with a block icon. If having the bend on either side overlaps with a block, the software uses a solid line.

    None — Uses solid lines. This format can improve performance slightly for updating very large models. With the Use classic diagram theme preference enabled, the software uses a solid line.

Programmatic Use

Parameter: EditorPathXStyle
Values: 'grad_pin' | 'hop' | 'none'
Default: 'grad_pin'

Option to use the scroll wheel to zoom without pressing the Ctrl key modifier. If you enable Scroll wheel controls zooming on macOS platforms with an Apple Magic Trackpad, a panning gesture causes zooming. For more information on zooming, see Zoom and Pan.

Programmatic Use

Parameter: EditorScrollWheelZooms
Values:'on'|'off'
Default:'on'

Specify whether the cover of hierarchical model elements should display a preview of the contents of the elements. For example, a Subsystem block can display a preview of the model that it contains. The setting only applies to elements that are added to the model after the setting is enabled.

Programmatic Use

Parameter: EditorContentPreviewDefaultOn
Values: 'on' | 'off'
Default: 'on'

Specify whether to enable the use of these smart editing cues to perform common model editing tasks quickly:

  • Quick insert — Add a block to a model by typing a block name.

  • Tear-off block addition — Add a complementary block from a block tear-off cue. For example, when you add a GoTo block, you can use a tear-off to add a corresponding From block.

  • Multiselection actions — Perform actions from the prompt that appears when you select multiple blocks.

  • Single-selection actions — Perform actions from the prompt that appears when you select a block or a signal.

Programmatic Use

Parameter: EditorSmartEditing
Values: 'on' | 'off'
Default: 'on'

Specify whether to be prompted to enter a key parameter when you add a block to a model.

Programmatic Use

Parameter: EditorSmartEditingHotParam
Values: 'on' | 'off'
Default: 'on'

Specify whether the Diagnostic Viewer should open docked in the Simulink model window. To open the Diagnostic Viewer, in the Simulink Toolstrip, on the Debug tab, in the Diagnostics section, click Diagnostics and select Diagnostic Viewer.

When you specify the value of a Simulink parameter as a variable or as an expression that contains variables, the Block Parameters dialog box and the Property Inspector can display the value of the variable or expression. The text box where you enter the parameter value displays the variable or expression on the left and the value on the right. For more information, see View Values of Parameters Set as Variables. For an example, see Turn Off Display of Variable Values in Block Parameters Dialog Box.

The value of the variable called x is 40. In the Block Parameters dialog box of a Gain block, the text box for entering the Gain value contains the expression "x+7" at the inner left edge, and the number 47 at the right edge.

Specify whether to enable the display of parameter values.

When you build a model or generate code using Embedded Coder®, the Code View displays the generated code alongside your model. You can use the Code View to:

  • Trace between model elements and the generated code.

  • Navigate between sections of the generated code.

  • View information about the generated code such as static code metrics and code profiling results.

Model File Pane

Specify the default file format for new models and libraries.

  • SLX — Save new models and libraries in SLX format

  • MDL — Save new models and libraries in MDL format

Programmatic Use

Parameter: ModelFileFormat
Values: 'mdl' | 'slx'
Default: slx

Specify whether to save a small screenshot of the model with the SLX file to display in the Current Folder browser preview pane.

Tips

If your model is large and you want to reduce the time the model takes to save, clear this parameter to avoid saving thumbnail model images.

Programmatic Use

Parameter: SaveSLXThumbnail
Default: on
Values: 'on' | 'off'

Specify whether to notify if a different MATLAB session changes the model on disk while you are updating or simulating the model. When Updating or simulating the model is enabled, use Action in Model File Preferences to specify the action to take if the model has changed. For more information, see Model File Change Notification.

Tips

To programmatically check whether the model has changed on disk since it was loaded, use the function slIsFileChangedOnDisk.

Programmatic Use

Parameter: MDLFileChangedOnDiskChecks
Type: struct, field name: CheckWhenUpdating
Values: true | false | 1 | 0
Default: true

Select the action to take if the file has changed on disk since it was loaded. This parameter is enabled by the Updating or simulating the model parameter.

  • Warning — Displays a warning in the MATLAB Command Window.

  • Error — Displays an error. If simulating programmatically, the error appears in the MATLAB Command Window. If simulating interactively, the error appears in a Simulation Diagnostics window.

  • Reload model (if unmodified) — Reloads if the model is unmodified. If the model is modified, the prompt dialog box appears.

  • Show prompt dialog — Shows prompt dialog box in which you can choose to close and reload or ignore the changes.

For more information, see Model File Change Notification.

Tips

To programmatically check whether the model has changed on disk since it was loaded, use the function slIsFileChangedOnDisk.

Programmatic Use

Parameter: MdlFileChangedOnDiskHandling
Values: 'Warning' | 'Error' | 'Reload model (if unmodified)' | 'Show prompt dialog'
Default: 'Warning'

Specify whether to notify if a different MATLAB session changes the model on disk while, for example, you are editing the model. For more information, see Model File Change Notification.

Any interactive operation that modifies the block diagram, for example, adding a block, causes a warning dialog box to appear.

Any programmatic operation that causes the block diagram to be modified, for example, a call to set_param, causes a warning in the MATLAB Command Window.

Tips

To programmatically check whether the model has changed on disk since it was loaded, use the function slIsFileChangedOnDisk.

Programmatic Use

Parameter: MDLFileChangedOnDiskChecks
Type: struct, field name: CheckWhenEditing
Values: true | false | 1 | 0
Default: true

Specify whether to notify if a different MATLAB session changes the model on disk while you are saving the model.

When the notification is enabled, saving the model in the Simulink Editor causes a dialog box to appear. In the dialog box, you can choose to overwrite or save with a new name.

The save_system function displays an error, unless you use the OverwriteIfChangedOnDisk option.

For more information, see Model File Change Notification.

Tips

To programmatically check whether the model has changed on disk since it was loaded, use the function slIsFileChangedOnDisk.

Programmatic Use

Parameter: MDLFileChangedOnDiskChecks
Type: struct, field name: CheckWhenSaving
Values: true | false | 1 | 0
Default: true

Specify whether to automatically save a backup copy of the model before updating or simulating.

The copy is saved in the same directory as the model, with the name MyModel.slx.autosave or MyModel.mdl.autosave.

If you open or load a model that has a more recent autosave copy available, then after the model loads, a dialog box prompts to restore, ignore, or discard the autosave copy. If multiple models are involved, then the Model Recovery dialog box appears.

For each model listed, you can select any of the options in this table.

OptionResult
RestoreOverwrite the original model file with the autosave copy and delete the autosave copy. The software will close the model and reload from the restored file. If you select Keep a copy of original model file, you can save copies of the original model files named MyModel.slx.original or MyModel.mdl.original.
Delete AutosaveDelete the autosave copy.
IgnoreLeave the model and the autosave copy untouched. This setting is the default. The next time you open the model, the Model Recovery dialog will reappear and you can choose to restore or delete autosave files.

Alternatively, click the Restore All, Delete All, or Ignore All button to select that option for all listed models.

Closing a modified model deletes any autosave copy.

The software might not autosave a model for these reasons:

  • Autosave does not occur for models that are part of the MATLAB installation, so you do not create autosave copies of those models.

  • Autosave does not occur if the autosave file or location is read-only.

  • Autosave does not occur in the Parallel Computing Toolbox™ software.

  • If a segmentation violation occurred, then the last autosave file for the model reflects the state of the autosave data prior to the segmentation violation. Because Simulink models might be corrupted by a segmentation violation, the software does not autosave a model after a segmentation violation occurs.

Programmatic Use

Parameter: AutoSaveOptions
Type: struct, field name: SaveOnModelUpdate
Values: true | false | 1 | 0
Default: true

Specify whether to automatically save a backup copy of the model when overwriting with a newer Simulink version.

The backup copy is saved in the same directory as the model, with the name MyModel.slx.Version or MyModel.mdl.Version, where Version is the last version that saved the model, for example, R2010a.

Tips

To recover the original model, rename the backup copy to MyModel.mdl or MyModel.slx by deleting the Version suffix.

Programmatic Use

Parameter: AutoSaveOptions
Type: struct, field name: SaveBackupOnVersionUpgrade
Values: true | false | 1 | 0
Default: true

This Simulink Online preference lets you specify whether to automatically save a backup copy of modified models when you exit a Simulink Online session.

The copy is saved in the same directory as the model, with the name MyModel.slx.autosave or MyModel.mdl.autosave.

Specify whether to be notified when loading a model last saved in an older Simulink version. The notification appears in the MATLAB Command Window.

Tips

  • Run the Upgrade Advisor to convert the block diagram to the format of the current Simulink version.

  • For advice on upgrading a model to the current Simulink version, see Model Upgrades.

Programmatic Use

Parameter: NotifyIfLoadOldModel
Values: 'on' | 'off'
Default: off

Specify whether to load a model last saved in a newer Simulink version.

  • When this option is selected and you try to load a model last saved in a newer Simulink version, the model does not load, and an error message appears in the MATLAB Command Window.

  • When this option is cleared and you try to load a model last saved in a newer Simulink version, the model loads, and a warning message appears in the MATLAB Command Window.

Tips

If possible, use the Save As option to convert the block diagram to the format of the desired Simulink version. The Save As option allows you to save a model created with the latest Simulink version in formats used by earlier versions. See Export Model to Previous Version of Simulink.

Programmatic Use

Parameter: ErrorIfLoadNewModel
Values: 'on' | 'off'
Default: on

Specify whether to load a model that is shadowed by another file of the same name higher on the MATLAB path.

  • When the option is enabled and you try to load a shadowed model, the model does not load, and an error message appears in the MATLAB Command Window.

    The option applies when you try to open or load a model or library by either:

    • Selecting a file in the current folder browser

    • Calling open_system or load_system with a path to a file in a different folder to the current folder

  • When the option is not enabled and you try to load a shadowed model, the model loads, and a warning message appears in the MATLAB Command Window.

Programmatic Use

Parameter: ErrorIfLoadShadowedModel
Values: 'on' | 'off'
Default: off

Specify whether to verify the signature on a protected model before opening the model.

When enabled, you cannot load a protected model that does not have a verified digital signature.

An error message appears if the signature verification process finds any of the these conditions:

  • The protected model was changed after it was signed.

  • The protected model was not signed.

  • The protected model was signed with an expired certificate.

  • The protected model was self-signed with a certificate issued by the author.

  • The protected model was signed with a missing or invalid certificate.

  • The certificate in your system certificate authority store is missing or invalid.

  • The model was signed with an invalid key.

Verification does not check if the certificate expired or was revoked after the protected model was signed.

Verification runs when you try to open or load a protected model by:

  • Simulating or generating code for a model that references the protected model

  • Performing an action that updates the diagram for a model that references the protected model

  • Opening the web view of the protected model

  • Opening the protected model report

You can suppress the diagnostic for an unverified protected model when the error message appears in the Diagnostic Viewer. The error cannot be suppressed if the signature is not valid because model was changed after it was signed.

Programmatic Use

Parameter: ProtectedModelValidateCertificate
Values: 'on' | 'off'
Default: off

Specify whether opening a model prompts you to open the project that contains a model.

For more information on projects, see Create a Project from a Model.

Programmatic Use

expand all

To get the value that a preference is set to programmatically, use get_param(Object,ParameterName,...ParameterNameN). For example:

get_param(0,'EditorModernTheme')

To set preferences programmatically, set the root parameter using set_param(Object,ParameterName,Value,...ParameterNameN,ValueN). For example:

set_param(0,'EditorModernTheme','off')

Note

Parameters set programmatically do not persist between Simulink sessions.

Version History

Introduced before R2006a

expand all