how to use set_param in a subsystem to change values of block same subsystem

5 visualizaciones (últimos 30 días)
Hi
I m trying to use set_param command to change values of a block of a subsystem(without mask).
The Embedded MATLAB function that contains the set_param command and the block whose values are to be changed lie in the same subsystem.
i m not sure if it is possible but through Documentation I managed following command
eml.extrinsic('set_param');
eml.extrinsic('num2str');
set_param('basicblock/Subsystem//Switch','Threshold',num2str(t));
i also tried Simple
set_param('basicblock/Subsystem/Switch','Threshold',num2str(t));
but both above commands are giving error. i am sure i am wrong with syntax for that mechanism.
help will be appreciated.
Thanx
--Regards Piyush
  1 comentario
Seth Popinchalk
Seth Popinchalk el 20 de Feb. de 2011
I suggest rewriting this question to be: "How do I change the threshold of a Switch block dynamically?"

Iniciar sesión para comentar.

Respuestas (2)

Seth Popinchalk
Seth Popinchalk el 20 de Feb. de 2011
In order to change the threshold of a switch, I recommend setting the threshold to .5 and using a Relational Operator to compare the signal to the computed threshold. The output of the Relational Operator can then connect to the control port on the Switch.
It is always preferable to use a signal to express things that change dynamically rather than SET_PARAM to modify a parameter at every step.

sonal jaiswal
sonal jaiswal el 20 de Feb. de 2011
thnks for ur suggestion sir... bt i m having the same problem and i want to change the block parameters using same functionality of set_param('basicblock/Subsystem/Switch','Threshold',num2str(t)); urs suggestion r always invited..
  3 comentarios
sonal jaiswal
sonal jaiswal el 24 de Feb. de 2011
i have to use the set_param command in the same systemblock in which i m writing this command...value of "t" will keep changing i m using it on Integrator block actually but my problem is same as the one in above question..
Kaustubha Govind
Kaustubha Govind el 24 de Feb. de 2011
You cannot change the Threshold Value for the switch during model execution (as I assume you are doing from an Embedded MATLAB block) - that is why Seth suggested setting the switch Threshold to a constant value of 0.5, and connecting the output of the Relational Operator to the Switch block, since its output is always either TRUE (1) or FALSE (0).

Iniciar sesión para comentar.

Categorías

Más información sobre Schedule Model Components en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by