Guy on Simulink

Simulink & Model-Based Design

Upgrading Simulink Libraries with Forwarding Tables and Transformation Functions 3

Posted by Guy Rouleau,

If you create and maintain Simulink libraries used in many models, or by many people, I think you will like this R2012a new feature: Interactive Library Forwarding Tables for Updating Links.

Note: Library Forwarding Tables have been around for a long time, but they used to be available through the command line only. This new feature in R2012a adds an enhanced interface to this old capability: set_param('Lib1', 'ForwardingTable', {{'Lib1/A', 'Lib2/A'} {'Lib1/B', 'Lib1/C'}});.

The Challenge

Let's say I create a library block with 2 mask parameters, a and b

Initial Library

A few weeks or months later, I decide to modify the library and combine a and b into only one, equivalent parameter c:

Modified Library

The next time a user will open his model using this library block, he will receive a warning like the following:

Warning: In instantiating linked block 'testMdl/Subsystem' : My
New Block block (mask) does not have a parameter named 'a

and the value for the new parameter c will be the default coming from the library. a and b will be lost.

The Solution

To avoid loosing values for a and b stored in the model, you can write a transformation function.

First, go to the File menu of the library. In the Library Properties dialog, go to the Forwarding Table tab and add an entry for your block:

Library forwarding table

Create a transformation function to process the value of a and b stored in the model and create the new value for c.

Example transformation function

I recommend going through the documentation section Making Backward-Compatible Changes to Libraries for more details and examples of the syntax to use in this function.

With this transformation applied, your users will be happy to see that the values they had previously set for a and b are kept:

Before and After

Now it's your turn

Of course, the example above is very simple, to highlight the concept. Give a look at the documentation section Making Backward-Compatible Changes to Libraries and let us know if this functionality is useful for you by leaving a comment here

3 CommentsOldest to Newest

Han Geerligs replied on : 1 of 3

Hi Guy,

thanks for introducing this feature. I was not aware of it.

I was wondering how this feature relates to the slupdate command: is table forwarding also expected to be used for “updating” standard Simulink blocks?

Or maybe the slupdate command will be deprecated?

Any information on this is welcome.


Bob replied on : 2 of 3

Hi, this doubt does not have relationship with example but anyway, what do you could recommend for the optimization routes in simulink?

Ion-Cristian Stefan replied on : 3 of 3

The example is very good and useful. Thanks Guy! But what would have been even more useful, is an example where you add two parameters to the new block. For example, besides the ‘c’, another ‘d’ that could be the division result of ‘a’ and ‘b’. This is what I am facing now and am not sure how to proceed. The Matlab help doesn’t offer much information, it only states that you should include more functions in the transformation function.

But otherwise, great tutorial!

Add A Comment

Your email address will not be published. Required fields are marked *

Preview: hide