Linked Blocks - MATLAB & Simulink (original) (raw)
Main Content
When you add a library block or a Subsystem block from a library to a Simulink® model, a referenced instance of the library block is created. Such referenced instance of a library block is called a linked block and contains link or path to the parent library block. The link or path allows the linked block to update when the library block is updated.
To optimize the performance, the child blocks (and the parameters) of a linked block are not saved with the Simulink model. When such a model is loaded and viewed, the child blocks are referenced from the parent library. If you change the parameter value of a child block of such a linked block, the changed information is saved as linked data in the model.
Note
The tooltip for a linked block shows the name of the parent library block.
To browse the parent library and other libraries in the Library Browser, right-click the block and select > . This option is available for all libraries that are added to the Library Browser. Alternatively, to view only the parent library block of a linked block, right-click the block and select > or press Ctrl + L. This option is available for the blocks that are linked and not for the Simulink built-in blocks.
To prevent unintentional disabling of library links and accidental changes to your library blocks, you can lock the links between a parent library block and its linked blocks, and hide the block implementation details. For more information, see Lock Links to Blocks in a Library and Hide Library Block Details in Create Custom Library.
When you edit a parent library block (either in the Simulink Editor or from the command line), Simulink updates the changes in the linked blocks. The outdated links are updated when you:
- Simulate or update the model.
- Use the find_system command.
- On the Modeling tab, select > (or press Ctrl+K).
- Load the model or library (only the visible links are updated).
- Use
get_param
to query the link status of the block (seeControl Linked Blocks Programmatically).
You can use theLinkStatus
parameter or theStaticLinkStatus
parameter to query the link status.LinkStatus
: First updates the linked block and then returns the link status.StaticLinkStatus
: Returns the link status without updating the linked block.
Selective usage ofStaticLinkStatus
overLinkStatus
can result in better Simulink performance. For more information onStaticLinkStatus
andLinkStatus
, seeControl Linked Blocks Programmatically.
Rules for Linked Blocks
- You can change the values of a linked block parameter (including the existing mask) in the mask dialog box.
- To allow the library block initialization code to change the values of a linked block parameter, select the Allow library block to modify its contents check box in theInitialization pane of the library block.
- It is not recommended to set callback parameters for a linked block.
- If the reference library block of a linked block is a subsystem, you can make nonstructural changes such as changing the parameter value of the linked subsystem. To make structural changes to a linked block, disable the link of the linked block from its library block (See Disable or Break Links to Library Blocks).
- During model compilation, Simulink may open some libraries implicitly to fully instantiate or load the model. However, to optimize memory usage, Simulink closes these libraries after the compilation. You must open the libraries explicitly instead of depending on the implicit opening by Simulink, to ensure the libraries do not close after the compilation.