Referencing 1) Simulink Model Components In Subsystems and 2) Workspace variables

I need to access / change simulink model component parameters (such as gain values) when using subsystems. I can access the root level of the simulink model with "set_param([bdroot '/GainBlock1'],'Gain',str)" but how would i do the same in a subsystem. The other question I have is very similar. I would also like to change workspace variables using similar method, but again I cant get it to work. Your help really appreciated Kind regards, Ian

回答 (1 件)

Sebastian Castro
Sebastian Castro 2015 年 7 月 29 日
For your first question, you should be able to the following without any issues:
>> set_param([bdroot '/Subsys/Subsubsys/BlockName'])
For your second question, what type of workspace variables are you concerned about? I'm guessing it's not the MATLAB base workspace, because those you can change directly in the Command Window:
>> x = 2;
Are you perhaps also working with model references and model workspaces?
- Sebastian

1 件のコメント

Ian Binns
Ian Binns 2015 年 8 月 6 日
編集済み: Ian Binns 2015 年 8 月 6 日
Thanks Sebastian, I have it working at last, although I seem to have hit another issue. I have a Simulink model that I would like to attach listeners to but not using the startfnc as I would prefer to do this dynamically as I change the current GUI figure. Unfortunately I can do this at anytime from the command line using "add_event_listener(....)" but it never works from a function. Any idea what i'm missing here. (apologies as i'm new to Matlab and this may be very obvious to most) Note: When adding the "add_event_listener(....)" into the function I don't get any errors and lines after do still work, yet no listener shown in Simulink)

この質問は閉じられています。

タグ

質問済み:

2015 年 7 月 29 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by