Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
Bjoern
Bjoern le 11 Juin 2012
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 commentaire
Bjoern
Bjoern le 11 Juin 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_

Connectez-vous pour commenter.

Réponse acceptée

Bjoern
Bjoern le 11 Juin 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.

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by