How to change value of a constant block that's inside of a library

8 views (last 30 days)
I programmatically want to change the value of a Constant Block inside a library. It works great but I get a warning that I'm modifying the internals of a library block:
set_param(gcb, 'Value', '1');
Warning: Overriding parameters of 'MyModel/MyLib/Constant' which is inside a library link. These changes can be changed, propagated, or viewed using the 'Link Options' menu item
The intent of the library is to enable a GUI to change the Constant block during run-time hence I can't have the warnings.
.
I've tried to solve the issue by adding a library mask parameter to hold the value together with a callback updating the Constant block. This works except that the callback doesn't get executed during run-time (hence I can't change the parameter from GUI during run).
Please let me know how to do this. Thanks!!
  1 Comment
Bjoern
Bjoern on 11 Jun 2012
BTW for the mask parameter mentioned above: If I could execute the "Mask Dialog Parameter Callback" after updating the value parameter my problem would be solved:
_set_param('MyModel/MyLib', 'MyGuiValue', '5');_
_??EXECUTE CALLBACK FOR MASK PARAMETER: MyGuiValue_

Sign in to comment.

Accepted Answer

Bjoern
Bjoern on 11 Jun 2012
I found a good way if anyone's interested:
Don't use a Mask Parameter-Callback to change the Constant Block. Instead, reference the Mask Parameter inside the Constant Block. Now all that is needed is to change the Mask Parameter (here MyGuiValue), something like:
set_param('MyModel/MyLib', 'MyGuiValue', '5')
and the simulation picks it up correctly.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!