Name of Bus at input or output port of a block

조회 수: 7 (최근 30일)
Cory Dinkle
Cory Dinkle 2022년 4월 21일
편집: Cory Dinkle 2022년 4월 22일
Hello! I am trying to determine the name of some busses at the input and output ports of a block. How could I do this programatically?
For example, I would like to enter a series of commands into the Command Window that would return the names "Inbus" and "Inbus2" for the inputs into 'SubsystemName' and "Outbus" for the output, returned as strings. The signals themselves are not named (and will not be named). I was hoping it was something that could be done with get_param(gcb,????), but there doesn't seem to be a function that returns the Bus names.
Thanks in advance!

채택된 답변

Fangjun Jiang
Fangjun Jiang 2022년 4월 22일
편집: Fangjun Jiang 2022년 4월 22일
"Inbus" and "Inbus2" here are the tag names of the "From" block. They have nothing to do with the bus name, of curse except that you make it the same as the bus name. To get it
get(gcbh,'GotoTag')
To get the bus name, the bus needs to be named somewhere (preferably at its source), then at the line connecting the "From" block and the "SubsystenName" block, turn on signal name progpagation. Update the model, pass without any error.
Then follow this example
model='slexBusExample';
open_system(model)
block='slexBusExample/Subsystem5/Subsystem2';
lh=get_param(block,'LineHandles');
in1=lh.Inport(1);
set(in1,'SignalPropagation','on');% no need here in this example since this is the source of the bus name
BusName=get(in1,'Name')
BusName = 'sinusoidal'
% in case the bus name is not named here
sph=get(in1,'SrcPortHandle');
>> BusName=get(sph,'PropagatedSignals')
BusName =
'sinusoidal'
  댓글 수: 8
Fangjun Jiang
Fangjun Jiang 2022년 4월 22일
Then it is not that hard. Start from the subsystem block, find its input and output line handles. Follow the line, find the source block handle or destination block handle and you will get it.
Cory Dinkle
Cory Dinkle 2022년 4월 22일
Thanks!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by