Parameterize Simulink Goto and From
25 views (last 30 days)
Is it possible to parameterize the from and goto tag's using a mask?
In my case, I am trying to share a single multiplier and I want to use the same subsystem as a hook into the multiply with a parameterized name. Each signal pair I mux into the multiply would have it's own prefix and then I would select the tag in the multiplier itself
Ideally, I would even be able to construct a string for the tag like: [name '_mult_in'] [name '_mult_out']
Sebastian Castro on 9 Apr 2015
I answered to the previous question you referred to: http://www.mathworks.com/matlabcentral/answers/139841-how-to-create-dynamic-goto-tag-names-in-simulink
In that answer, I only mentioned the case for the Goto block, and not the corresponding From block(s). I'm guessing you'd have to do some extra "magic" for your case to find corresponding tag names. For example, prior to changing the block tag name:
gotoTagName = get_param(gcb,'GoToTag');
fromBlks = find_system(bdroot,'GoToTag',gotoTagName);
Then, you can modify the tag names of the Goto block ( gcb , or 'get current block') and the list of From blocks ( fromBlks ) in one fell swoop.
Jason Ghidella on 1 Apr 2015
I have a few extra questions that would help me answer your question. First, the parameter name for the goto and from tags need to be the same in order to match where the from is getting its signal from. So in your example param_goto and param_from would not work. Both need to be the same name, for example something like:
My second question is how are you using the from and goto tags? You mention that you want to have it in a library, this suggests this will be a component. Now are the goto and from tags created and consumed in the same component, or do they need to be accessible throughout the model? If they are self contained, then by simply masking the component where the got and from blocks are used, you get a reusable component that you can put in to a library. The masked block provides a local workspace for that block, so you don't need to parametise the tag. Let me know if this helps.