How to create dynamic goto tag names in Simulink?

24 ビュー (過去 30 日間)
Marina
Marina 2014 年 7 月 2 日
コメント済み: Marina 2015 年 4 月 9 日
I am developing some libraries and I want that most of the signals of the components comunicate with other components without visual links, so that I am using global GOTOs. My idea is that the final user will be able to specify the FROMs of a component in the component mask. (In anyone know other way to do that without global GOTOs it would be great).
The problem is that if I insert two times the same component from the library I will get two GOTOs with the same name. As the name of the component automatically changes ("Component", "Component1", "Component2"...) i would like to add a refference to the component's name in the GOTO tag name, something like:
Tag name: strcat(gcb,'_goto_name')
where gcb is a function that gets the block's path.
Is that possible? How could I do it? If not I think I could also activate a callback with code to do that everytime the name of a system changes...
Thank you all
  1 件のコメント
Aaron
Aaron 2015 年 3 月 27 日
編集済み: Aaron 2015 年 3 月 27 日
I see you got no response. I just asked the same question again:

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

回答 (1 件)

Sebastian Castro
Sebastian Castro 2015 年 4 月 9 日
You should be able to make a self-modifying block using Block Callbacks.
To do this, you can right-click the block and select Properties, then go to the Callback tab. In one of those callbacks, probably "NameChangeFcn", you can add the following code:
blkName = get_param(gcb,'Name');
set_param(gcb,'GotoTag',[blkName '_goto_name']);
- Sebastian
  1 件のコメント
Marina
Marina 2015 年 4 月 9 日
Thanks!
I have tried it with Simulink Callbacks CopyFnc and NameChangeFcn and it works.
Just to note that if the component has a mask, the name of the tag has to be modifyable fom the mask and what you should modify is the mask value, not the Goto Tag name.
Also, when the Goto is modified the Froms also need to be modified as Sebastian explains in http://www.mathworks.com/matlabcentral/answers/194890-parameterize-simulink-goto-and-from
Marina

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

カテゴリ

Help Center および File ExchangeEvent Functions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by