Create and Work with Linked Blocks

About Linked Blocks

A linked block is an instance of a library block and contains a link to that library block that serves as the block type's prototype. The link consists of the path of the library block that serves as the instance's prototype. The link allows the linked block to update whenever the corresponding prototype in the library changes (Update a Linked Block). This ensures that your model always uses the latest version of the block.

    Note:   The data tip for a linked block shows the name of the library block it references (see Block Tool Tips).

You can change the values of a linked block's parameters (including in an existing mask). You cannot add a new mask for linked blocks or edit the mask setup, that is, add or remove mask parameters or change mask behavior.

Also, you cannot set callback parameters for a linked block. If the linked block's prototype is a subsystem, you can make nonstructural changes to the contents of the linked subsystem (see Modify Linked Blocks).

Create a Linked Block

To create a linked block in a model or another library:

  1. Open your model.

  2. Open the Simulink® Library Browser (see Copy Blocks to Your Model), or another library.

  3. Use the Library Browser to find the library block that serves as a prototype of the block you want to create (see Browse Block Libraries and Search Block Libraries).

  4. Drag the library block from the Blocks pane and drop it into your model.

Update a Linked Block

Simulink updates out-of-date linked blocks in a model or library when you:

  • Load the model or library.

  • Run the simulation.

  • Use the find_system command.

  • Query the LinkStatus parameter of a block, using the get_param command (see Check and Set Link Status Programmatically ).

      Note   Querying the StaticLinkStatus parameter of a block does not update any out-of-date linked blocks.

  • Save changes to a library block, then Simulink automatically refreshes all links to the block in open Model Editor windows.

When you edit a library block (in the Model Editor or at the command line), then Simulink indicates stale links which are open in the Model Editor by displaying the linked blocks grayed out. Simulink refreshes any stale links to edited blocks when you activate the Model Editor window, even if you have not saved the library yet.

To manually refresh links:

  • Select Simulation > Update Diagram (or press Ctrl+D).

  • Select Diagram > Refresh Blocks (or press Ctrl+K) to refresh links.

  • Select Go To Library Link.

Modify Linked Blocks

You cannot make structural changes to linked blocks, such as adding or deleting lines or blocks to the block diagram of a masked subsystem. If you want to make such changes, you must disable the linked block's link to its library prototype (see Disable Links to Library Blocks ).

Parameterized Links

If you change parameter values inside a linked block, you create a parameterized link. You can change the values of any masked subsystem linked block parameter that does not alter the block's structure, e.g., by adding or deleting lines, blocks, or ports. An example of a nonstructural change is a change to the value of a mathematical block parameter, such as the Gain parameter of the Gain block. A linked subsystem block whose parameter values of inner blocks differ from their corresponding library blocks is called a parameterized link. Changing the top-level mask values does not create a parameterized link.

When saving a model containing a parameterized link, Simulink saves the changes to the local copy of the subsystem together with the path to the library copy in the model's file. When you reopen the system, Simulink copies the library block into the loaded model and applies the saved changes.

    Tip   To determine whether a linked block's parameter values differ from those of its library prototype, open the linked block's block diagram in an editor window. The linked block's library link indicator (if displayed) changes to a red arrow and the title bar of the editor window displaying the subsystem displays "Parameterized Link" if the linked block's parameter values differ from the library block's parameter values.

See Display Library Links.

Self-Modifying Linked Subsystems

Simulink allows linked subsystems to change their own structural contents without disabling the link. This allows you to create masked subsystems that modify their structural contents based on mask parameter dialog box values.

Find a Linked Block's Prototype

To find the source library and the prototype of a linked block, right-click the linked block and select Library Link > Go To Library Link.

Alternatively, select the linked block and select Diagram > Library Link > Go To Library Link.

If the library is open, Simulink selects and highlights the library block and makes the source library the active window. If the library is not open, Simulink first opens it and then selects the library block.

Find Linked Blocks in a Model

Use the libinfo command to get information about the linked blocks in the model and which library blocks they link to. The ReferenceBlock property gives the path of the library block to which a block links.

Was this topic helpful?