Error in Using set_param

17 次查看(过去 30 天)
William
William 2014-7-14
评论: Fuli Wang 2019-12-13
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.

采纳的回答

William
William 2014-7-14
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 个评论
William
William 2014-7-15
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 2014-7-15
If x is a variable in the workspace, then you can use
set_param('dummy/Constant','Value','x')

请先登录,再进行评论。

更多回答(1 个)

Brian B
Brian B 2014-7-14
Try
set_param('dummy/Constant','Value','50')
Note that the value is also a string.
  4 个评论
William
William 2014-7-15
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 2019-12-13
x=50;
set_param('untitled/Constant','Value',num2str(x));

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by