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

4 ビュー (過去 30 日間)
Piyush
Piyush 2011 年 2 月 19 日
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
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
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.

sonal jaiswal
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
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
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 ExchangeProgrammatic Model Editing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by