Products & Services Industries Academia Support User Community Company

Learn more about Simulink   

Working with Library Links

Displaying Library Links

A model can have a block linked to a library block, or it can have a local instance of a block that is not linked. To enable the display of library links:

  1. In the Model Editor window, and from the Format menu, select Library Link Display.

  2. From the submenu, select either User (displays only links to user libraries) or All (displays all links).

    The library link indicator is an arrow in the bottom left corner of each block.

The color of the link arrow indicates the status of the link.

ColorStatus

Black

Active link

Grey

Inactive link

Red

Active and modified (parameterized link)

Disabling Links to Library Blocks

To make a structural change to a linked subsystem block, you need to disable the link between the block and the library block that serves as its prototype.

To disable a link:

  1. In the Model Editor window, select a subsystem block.

  2. From the Edit menu, select Link Options, and then select Disable link.

    The model breaks the library link and grays out the library link indicator. When a library block is disabled and it is within another library block (a child of a parent library block), the model also disables the parent block containing the child block.

Restoring Disabled or Parameterized Links

After you make structural changes to a linked subsystem block, you need to restore the link to its library block and resolve any differences between the two blocks. The Links Tool helps you with this task.

  1. In the Model Editor window, select a linked subsystem block with a disabled library link.

  2. From the Edit menu, select Link Options, and then select Resolve link.

    The Links Tool window opens.

    The table in the Edited links panel has the following columns:

    • Linked block — List of linked blocks. The list of edited links includes library links with structural changes, parameterized library links, and library links that were actively chosen to be resolved.

    • Action — Choose and action to perform on the linked block or library.

    • Library — List of library names and version numbers.

  3. From the Linked block list, select a block name.

    The Links Tool updates the Paths for selected link panel with links to the linked block in the model and in the library.

  4. From the Action list, choose one of two actions.

    Action ChoiceSimulink Action
    PushUpdates the library version with the changes you made in the model version of that subsystem.
    RestoreReplaces the version of the subsystem in the model with the version in the library.

    Choosing the Push all, Restore all or Clear all button selects an action for all linked blocks.

  5. Click OK or Apply.

    Simulink restores the library links to the selected subsystems in the model. The subsystem versions in the library and the model now match. If the link for a child that was structurally changed is restored, and there were no structural changes with its parent, the parent link is also restored.

    Changes pushed to the library are not saved until you actively save the library.

If a linked block name has a cautionary icon before it, the model has other instances of this block linked from the same library block, and they have different changes. Choose one of the instances (In this case, Braking chopper, Braking chopper 1, or Braking chopper 2) to push changes to the library block and restore links to the other blocks , or choose to restore all of them with the library version.

Determining Link Status

All blocks have a LinkStatus parameter and a StaticLinkStatus parameter that indicate whether the block is a reference block. The parameters can have these values.

StatusDescription
none

Block is not a reference block.

resolved

Resolved link.

Unresolved

Unresolved link.

Implicit

Block resides in library block and is itself not a link to a library block. For example, suppose that A is a link to a subsystem in a library that contains a Gain block. Further, suppose that you open A and select the Gain block. Then, get_param(gcb, 'LinkStatus') returns implicit.

Inactive

Link disabled.

Restore

Restores an inactive or disabled link to a library block and discards any changes made to the local copy of the library block. For example, set_param(gcb, 'LinkStatus', 'restore') replaces the selected block with a link to a library block of the same type, discarding any changes in the local copy of the library block. The function get_param never return Restore. It is only used with set_param.

Propagate

Restores an inactive or disabled link to a library block and pushes any changes made to the local copy to the library. The function get_param never return Propagate. It is only used with set_param.

Breaking a Link to a Library Block

You can break the link between a reference block and its library block to cause the reference block to become a simple copy of the library block, unlinked to the library block. Changes to the library block no longer affect the block. Breaking links to library blocks may enable you to transport a Masked Subsystem Example model as a standalone model, without the libraries.

To break the link between a reference block and its library block, first disable the link. Then select the block and choose Break Link from the Link Options menu. You can also break the link between a reference block and its library block from the command line by changing the value of the LinkStatus parameter to 'none' using this command:

set_param('refblock', 'LinkStatus', 'none')

You can also break links to library blocks when saving the model, by supplying arguments to the save_system command. See save_system in the Simulink reference documentation.

Fixing Unresolved Library Links

If Simulink is unable to find either the library block or the source library on your MATLAB path when it attempts to update the reference block, the link becomes unresolved. Simulink issues an error message and displays these blocks using red dashed lines. The error message is

Failed to find block "source-block-name" 
in library "source-library-name"
referenced by block
"reference-block-path".

The unresolved reference block appears like this (colored red).

To fix a bad link, you must do one of the following:

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS