Error in Using set_param

32 vues (au cours des 30 derniers jours)
William
William le 14 Juil 2014
Commenté : Fuli Wang le 13 Déc 2019
I've not been able to set the consant in the "constant" block. I used: set_param('dummy/Constant','x',50) but kept getting eroor "Constant block does not have a parameter named 'x'". 'dummy' is the model name.
Thanks.

Réponse acceptée

William
William le 14 Juil 2014
I still got error: "Invalid setting in Constant block 'Constant' for parameter 'Value'. 'x' is in the place of the 'constant' block where the numeric value is given.
  5 commentaires
William
William le 15 Juil 2014
how can I replace the constant value with a variable (x in this case) & set x to the value I want? Thanks (I got with it worked with your suggestion above).
Brian B
Brian B le 15 Juil 2014
If x is a variable in the workspace, then you can use
set_param('dummy/Constant','Value','x')

Connectez-vous pour commenter.

Plus de réponses (1)

Brian B
Brian B le 14 Juil 2014
Try
set_param('dummy/Constant','Value','50')
Note that the value is also a string.
  4 commentaires
William
William le 15 Juil 2014
how can I replace the constant value with a variable (x in this case) & set x to the value I want? Thanks.
Fuli Wang
Fuli Wang le 13 Déc 2019
x=50;
set_param('untitled/Constant','Value',num2str(x));

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programmatic Model Editing 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