Using a variable for the Goto tag name
12 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Niklas Nylén
on 25 Apr 2014
Edited: Niklas Nylén
on 25 Apr 2014
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 Comments
Aaron
on 27 Mar 2015
What if the block is a library cell and cannot be modified http://www.mathworks.com/matlabcentral/answers/194890-parameterize-simulink-goto-and-from
More Answers (0)
See Also
Categories
Find more on Author Block Masks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!