필터 지우기
필터 지우기

Using a variable for the Goto tag name

조회 수: 18 (최근 30일)
Cristian JECU
Cristian JECU 2014년 4월 25일
댓글: Aaron 2015년 3월 27일
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.
Aaron
Aaron 2015년 3월 27일

댓글을 달려면 로그인하십시오.

추가 답변 (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