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

6 views (last 30 days)
Piyush
Piyush on 19 Feb 2011
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 Comment
Seth Popinchalk
Seth Popinchalk on 20 Feb 2011
I suggest rewriting this question to be: "How do I change the threshold of a Switch block dynamically?"

Sign in to comment.

Answers (2)

Seth Popinchalk
Seth Popinchalk on 20 Feb 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 on 20 Feb 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 Comments
Kaustubha Govind
Kaustubha Govind on 24 Feb 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).

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!