Guy on Simulink

Simulink & Model-Based Design

Another Good Reason to Use Simulink Projects

This week I discovered a super useful a feature of Simulink Projects.

Renaming a Library

If you are using Simulink Libraries to componentize your models, you very likely ran into the following situation at some point.

You create a library block, and use that block in a model:

Using a Library block

After some time, you decide that the library file needs to be renamed. The next time you open your model, here is what you get:

Library not found

Here are a few ways to deal with that, depending on how your library block is used.

Option 1 - Manual Update

Let's begin with the obvious one. If your library subsystem is used only once in one model, the quickest solution is probably to simply double-click on the missing link block and type the new name of the library:

Library not found

Option 2 - Forwarding Table

If your library is used by hundreds or thousands of users, you should definitely be using a Forwarding Table. I wrote a blog post on this topic some time ago so I will not go into deep details here.

For this post, let's just say that Forwarding Tables give you all the flexibility you need when re-organizing libraries, but requires some work to implement. I typically implement it only when I know many other users will be affected by the re-organization.

Forwarding Table

Option 3 - Simulink Project

If you are working on a project where you have library blocks used multiple times in various project-related models, you will love this feature.

When all your models and libraries are in a Simulink Project, if you rename a library file, the project will automatically run a dependency analysis and offer you to update all the instances of the blocks from the library.

Rename a library

Update Links

Simply click Rename and Update, and magic happens, the models now all use the renamed library:

Model using renamed library

Now it's your turn

Are you already taking advantage of this feature? What's is your preferred way to manage library reorganization? Let us know in the comments below.

  • print


To leave a comment, please click here to sign in to your MathWorks Account or create a new one.