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.

 Respuesta aceptada

William
William el 14 de Jul. de 2014

0 votos

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 comentarios

William
William el 15 de Jul. de 2014
>> set_param('dummy/Constant','X',50) Constant block does not have a parameter named 'X'
William
William el 15 de Jul. de 2014
>> set_param('dummy/Constant','x','50') Constant block does not have a parameter named 'x'
Brian B
Brian B el 15 de Jul. de 2014
The error is telling you what you need to know: There is no parameter named 'x'. The parameter is called 'Value'. Try EXACTLY THIS LINE:
set_param('dummy/Constant','Value','50')
William
William el 15 de Jul. de 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 el 15 de Jul. de 2014
If x is a variable in the workspace, then you can use
set_param('dummy/Constant','Value','x')

Iniciar sesión para comentar.

Más respuestas (1)

Brian B
Brian B el 14 de Jul. de 2014

0 votos

Try
set_param('dummy/Constant','Value','50')
Note that the value is also a string.

4 comentarios

William
William el 14 de Jul. de 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.
Brian B
Brian B el 14 de Jul. de 2014
Can you post the exact command that you tried? If I run
set_param('untitled/Constant','Value',50)
I get the error you describe. If I replace 50 with '50', I do not get an error.
William
William el 15 de Jul. de 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 el 13 de Dic. de 2019
x=50;
set_param('untitled/Constant','Value',num2str(x));

Iniciar sesión para comentar.

Categorías

Productos

Preguntada:

el 14 de Jul. de 2014

Comentada:

el 13 de Dic. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by