| Using Simulink | ![]() |
To create a link to a library block in a model, copy the block from the library to the model (see Copying and Moving Blocks from One Window to Another) or by dragging the block from the Library Browser (see Browsing Block Libraries) into the model window.
When you drag a library block into a model or another library, Simulink creates a copy of the library block, called the reference block, in the model or the other library. You can change the values of the reference block's parameters but you cannot mask the block or, if it is masked, edit the mask. Also, you cannot set callback parameters for a reference block. If the link is to a subsystem, you can make nonstructural changes to the contents of the reference subsystem (see Modifying a Linked Subsystem).
The library and reference blocks are linked by name; that is, the reference block is linked to the specific block and library whose names are in effect at the time the copy is made.
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 is displayed like this (colored red).
To fix a bad link, you must do one of the following:
Disabling Library Links
Simulink allows you to disable linked blocks in a model. Simulink ignores disabled links when simulating a model. To disable a link, select the link, choose Link options from the model window's Edit or context menu, then choose Disable link. To restore a disabled link, choose Restore link from the Link Options menu.
Modifying a Linked Subsystem
Simulink allows you to make any change to the local copy of an active library link that does not alter the structure of the local copy. Examples of nonstructural changes include changes to parameter values that do not affect the structure of the subsystem. Examples of structural modifications include adding or deleting a block or line or changing the number of ports on a block.
When you save the model containing the modified subsystem, Simulink saves the changes to the local copy of the subsystem together with the path to the library copy in the model's model (.mdl) file. When you reopen the system, Simulink copies the library subsystem into the loaded model and applies the saved changes.
Note
If you attempt to use the Simulink GUI to make a structural change to the local copy of an active library link, for example, by editing the subsystem's diagram, Simulink offers to disable the link to the subsystem. If you accept, Simulink makes the change. Otherwise, it does not allow you to make the structural change. Simulink does not prevent you from using set_param to attempt to make a structural change to an active link. However, the results of the change are undefined.
|
Propagating Link Modifications
If you restore a disabled link that has structural changes, Simulink prompts you to either propagate or discard the changes. If you choose to propagate the changes, Simulink updates the library version of the subsystem specified by the restored link with the changes made in the model's version of that subsystem. If you choose to discard the changes, Simulink replaces the version of the subsystem in the model with the version in the library. In either case, the end result is that the versions of the subsystem in the library and the model are exactly the same.
If you restore a disabled link to a block with nonstructural changes, Simulink enables the link without prompting you to propagate or discard the changes. To see the nonstructural parameter differences between the model's version of a library block and the library block itself, choose View changes from the Link options menu.
If you want to propagate or discard nonstructural changes, select the modified copy of the library block in the model, choose Link options from the model window's Edit or context menu, then choose Propagate/Discard changes. A dialog box appears that asks whether you want to propagate or discard the changes. If you elect to propagate the changes, Simulink applies the changes made to the model's copy of the libary block to the library block itself. If you elect to discard the changes, Simulink removes the changes from the model's copy of the block. In either case, the library and model versions of the block become the same.
Updating a Linked Block
Simulink updates out-of-date reference blocks in a model or library at these times:
LinkStatus parameter of a block, using the get_param command (see Library Link Status)
find_system command
| Working with Block Libraries | Updating Links to Reflect Block Path Changes | ![]() |
© 1994-2005 The MathWorks, Inc.