Unresolved linked library block: How to change the source block programmatically?

24 views (last 30 days)
Hi,
assume you have a linked library block in your model. The library is in the path and can be found, so the block is resolved and regularily displayed.
Now you change the library file name. Now the block is unresolved. To fix that you can double-click the block and change the path to the library in the "Source block" field. After hitting OK the block will resolve and show up normally again.
How to do that programmatically? The issue is that I cannot change the "ReferenceBlock" property in case the block is unresolved. It only works when it´s resolved. So I can change from one existing library to another existing library only but not from a missing library to a valid one.
Background: I have several linked blocks in the model but need to change the library names frequently. So I would need to go through the model each time and change the links manually. Apart from that Matlab (2014b) always crashes nearly after the first change and completely after the second one. So my hope would also be that it would survive if the change is done from the command window.
Is there a solution for it?

Answers (1)

Mandar Patwardhan
Mandar Patwardhan on 27 Jun 2017
To resolve library links programmatically, use the "SourceBlock" parameter instead of using the "ReferenceBlock" parameter.
  1 Comment
Giuseppe Avallone
Giuseppe Avallone on 28 Jul 2017
Hello. I have the same problem. I tried this way, but it results "Reference block parameter 'SourceBlock' is read-only".

Sign in to comment.

Categories

Find more on Custom Libraries in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!