Using a variable for the Goto tag name
11 次查看(过去 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.
0 个评论
采纳的回答
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 个评论
Aaron
2015-3-27
What if the block is a library cell and cannot be modified http://www.mathworks.com/matlabcentral/answers/194890-parameterize-simulink-goto-and-from
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Author Block Masks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!