# Guy and Seth on Simulink

## Upgrading Simulink Libraries with Forwarding Tables and Transformation Functions

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

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

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

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:

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

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:

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 Responses to “Upgrading Simulink Libraries with Forwarding Tables and Transformation Functions”

1. Han Geerligs replied on :

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

2. Bob replied on :

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

3. Ion-Cristian Stefan replied on :

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!

 Name (required) E-mail (required, will not be published) Website (optional) Spam protection (required): What is 3 + 4 ?

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>


If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).

Guy Rouleau and Seth Popinchalk are Application Engineers for MathWorks. They write here about Simulink and other MathWorks tools used in Model-Based Design.

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