open_system

Open Simulink model, library, subsystem, or block dialog box

Syntax

  • open_system(sys,'loadonly') example
  • open_system(sbsys,'window') example
  • open_system(sbsys,'tab')
  • open_system(blk,'mask') example
  • open_system(blk,'force')
  • open_system(blk,'parameter')
  • open_system(blk,'OpenFcn')

Description

example

open_system(obj) opens the specified model, library, subsystem, or block. This is equivalent to double-clicking the model or library in the Current Folder Browser, or the subsystem or block in the Simulink® Editor.

A model or library opens in a new window. For a subsystem or block within a model, the behavior depends on the type of block and its properties.

  • Any OpenFcn callback parameter is evaluated.

  • If there is no OpenFcn callback, and a mask is defined, the mask parameter dialog box opens.

  • Without an OpenFcn callback or a mask parameter, Simulink opens the object.

    • A referenced model opens in a new window.

    • A subsystem opens in a new tab in the same window.

    • For blocks, the parameters dialog box for the block opens.

To open a specific subsystem or block, you must load the model or library containing it. Otherwise Simulink returns an error.

You can override the default behavior by supplying a second input argument.

example

open_system(sys,'loadonly') loads the specified model or library without opening the Simulink Editor. This is equivalent to using load_system.

example

open_system(sbsys,'window') opens the subsystem sbsys in a new Simulink Editor window. Before opening a specific subsystem or block, load the model or library containing it. Otherwise Simulink returns an error.

open_system(sbsys,'tab') opens the subsystem in a new Simulink Editor tab in the same window. Before opening a specific subsystem or block, load the model or library containing it. Otherwise Simulink returns an error.

example

open_system(blk,'mask') opens the mask dialog box of the block or subsystem specified by blk. Before opening a specific subsystem or block, load the model or library containing it. Otherwise Simulink returns an error.

open_system(blk,'force') looks under the mask of a masked block or subsystem. It opens the dialog box of the block under the mask or opens a masked subsystems in a new Simulink Editor tab. This is equivalent to the Look Under Mask menu item. Before opening a specific subsystem or block, load the model or library containing it. Otherwise Simulink returns an error.

open_system(blk,'parameter') opens the block parameter dialog box or, for masked subsystems, the Mask Parameters dialog box.

open_system(blk,'OpenFcn') runs the block callback OpenFcn.

Examples

expand all

Open a Model

Open the f14 model.

open_system('f14')

Load a Model Without Opening it

Load the f14 model.

open_system('f14','loadonly')

Open a Subsystem

Open the Controller subsystem of the f14 model.

load_system('f14')
open_system('f14/Controller')

Open a Subsystem

Open the Controller subsystem of the f14 model.

load_system('f14')
open_system('f14/Controller')

Open a Subsystem in New Tab in Existing Window

Open the f14 model and open the Controller subsystem in a new tab.

f14
open_system('f14/Controller','tab')

Open a Subsystem in a Separate Window

Open a subsystem in its own Simulink Editor window.

open_system('f14')
open_system('f14/Controller','window')

Open a Referenced Model

Open the model sldemo_mdlref_counter, which is referenced by the CounterA model block in sldemo_mdlref_basic.

open_system('sldemo_mdlref_basic')
open_system('sldemo_mdlref_basic/CounterA')

The referenced model opens in its own Simulink Editor window.

Open Block Dialog Box

Open the block parameters dialog box for the first Gain block in the Controller subsystem.

load_system('f14')
open_system('f14/Controller/Gain')

Run Block Open Callback Function

Define an OpenFcn callback for a block and execute the block callback.

f14
set_param('f14/Pilot','OpenFcn','disp(''Hello World!'')')
open_system('f14/Pilot','OpenFcn')

The words Hello World appear on the MATLAB Command Prompt.

Open Masked Subsystem

Open the contents of the masked subsystem Vehicle in the model sf_car.

open_system('sf_car')
open_system('sf_car/Vehicle', 'force')

Open Multiple Systems with One Command

Create a cell array of two model names, f14 and vdp. Open both models using open_system with the cell array name.

models = {'f14','vdp'}
open_system(models)

Input Arguments

expand all

obj — Model, referenced model, library, subsystem, or block pathstring

Model, referenced model, library, subsystem, or block path, specified as a string. If the model is not on the MATLAB path, specify the full path to the model file. Specify the block or subsystem using its full name, e.g., f14/Controller/Gain, on an opened or loaded model. On UNIX® systems, the fully qualified path name of a model can start with a tilde (~), signifying your home directory.

Data Types: char

sys — Model or library pathstring

The full name or path of a model or library, specified as a string.

Data Types: char

sbsys — Subsystem pathstring

The full name or path of a subsystem in an open or loaded model, specified as a string.

Data Types: char

blk — Block or subsystem pathstring

The full name or path of a block or subsystem in an open or loaded model, specified as a string.

Data Types: char

Was this topic helpful?