필터 지우기
필터 지우기

How to find ports names on ReferenceModel block

조회 수: 11 (최근 30일)
Stephane
Stephane 2018년 12월 17일
답변: Alex Hirzel 2023년 1월 27일
Hello, I would like with a script to find the Inports names and Outports names of a ReferenceModel block which file is missing.
I tried to find it with the structure returned by get(gcbh). But no information.
If I save the model in ".mdl" I can find this information while I read it in text mode.
ModelReferenceVersion "1.4"
List {
ListType InputPortNames
port0 "SW_rad"
port1 "SW_radps"
port2 "IS_radps"
port3 "IS_rad"
}
List {
ListType OutputPortNames
port0 "VehicleSpeed_kmph"
port1 "TS_Nm_target" ....
So the information is saved but I don't know how to access to it.
Thank you.

답변 (2개)

Mayur Agnani
Mayur Agnani 2018년 12월 17일
Hi Stephane,
I understand that you want to get Inport and Outport names of a Reference model block.For getting names of port you can use
find_system(gcb,'BlockType','Outport')
find_system(gcb,'BlockType','Inport')
In your question you mentioed that that the files are missing for the Referenced block. For the above function to work you need to have files of the Referenced block.
Below is the link to find_system documentation
Mayur
  댓글 수: 1
Fang Fang
Fang Fang 2021년 3월 10일
hi Mr. Agnani,
will matlab search the source model (.slx) automatically and find the names of a reference model block? I have tried your method but it showed error

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


Alex Hirzel
Alex Hirzel 2023년 1월 27일
For future reference, as of MATLAB 2020b, it is possible to use the following to get a structure that can be parsed into the port names and numbers. These numbers can then be fed to e.g. add_line.
inports = get_param(handle, 'InputPortNames');
outports = get_param(handle, 'OutputPortNames');

카테고리

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

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by