Using a variable for the Goto tag name

18 次查看(过去 30 天)
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Author Block Masks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by