how to use set_param in a subsystem to change values of block same subsystem
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
Seth Popinchalk
2011-2-20
I suggest rewriting this question to be: "How do I change the threshold of a Switch block dynamically?"
回答(2 个)
Seth Popinchalk
2011-2-20
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.
0 个评论
sonal jaiswal
2011-2-20
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 个评论
sonal jaiswal
2011-2-24
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
2011-2-24
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).
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Schedule Model Components 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!