Guy and Seth on Simulink

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

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.

–Han

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

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

What is 5 + 8?

Preview: hide

These postings are the author's and don't necessarily represent the opinions of MathWorks.