フィルターのクリア

Using a variable for the Goto tag name

18 ビュー (過去 30 日間)
Cristian JECU
Cristian JECU 2014 年 4 月 25 日
コメント済み: Aaron 2015 年 3 月 27 日
Hello,
I would like to use a variable string defining a Goto tag name.
I have several subsystems each containing a Goto block with a different tag name. The subsystems are identically build, the difference between them is the state of a switch and the goto tag name. I am using this to define the state of the corresponding equipment in a electrical network. The subsystems are masked and demand a popup parameter with the state of the corresponding equipment. This is changes manually The address to the corresponding equipment is assured by the goto tag name. As this model mat be used by several people I would like to assure that there is no error in switching the wrong equipment. As I will use this in a real time simulation and there are many subsystems I need this solution to be as fast as possible (kind of excluding the solution of a S function with an external file to call this tag and setting the name of the masked subsystem - this was my first approach)
My question: Would it be possible to: either define a variable in the mask parameters and use this variable instead of the goto tag name, therefore setting the goto tag as the string imputed in the mask. or defining the goto tag as usual and recalling this tag name in the mask (title name, as an information that may not be editable).
Thank you in advance for any idea.

採用された回答

Niklas Nylén
Niklas Nylén 2014 年 4 月 25 日
編集済み: Niklas Nylén 2014 年 4 月 25 日
You will need to add some code to the dialog callback in the parameter pane of the mask editor to change the tag, see attached image. If the mask parameter is named myTag you can do it like this:
tag = get_param(gcb,'myTag'); % Read the parameter myTag from the mask
b = find_system(gcb,'LookUnderMasks','on','BlockType','Goto'); % find the Goto block
set_param(b{1},'GotoTag',tag); % set the tag to myTag
  2 件のコメント
Cristian JECU
Cristian JECU 2014 年 4 月 25 日
Thank you Niklas. It's exactly what I needed. I added a clear command at the end for keeping the workspace clean.
Aaron
Aaron 2015 年 3 月 27 日

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAuthor Block Masks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by