Rename an inport and outport of Subsystem

조회 수: 11 (최근 30일)
Lucas S
Lucas S 2019년 4월 2일
답변: Pruthvi G 2019년 4월 3일
Hello !
I am parsing a text file with matlab and trying to create a Simulink model from Matlab.
new_system(link_NameValue);
add_block('simulink/Ports & Subsystems/Subsystem',[link_NameValue '/' link_NameValue]);
set_param(gcb,'Description',sprintf('%s ==> %s', link_SourceNameValue, link_TargetNameValue));
set_param('On_Off/On_Off/In1','Port number',link_SourcePortNameValue);
I would like to rename name of Input In1 and Output Out1 of the subsystem with some parsed value.
I have tried this but returned me :
Inport block does not have a parameter named 'Port number'
Tried also with 'port' instead of 'Port number' but returned me :
Port number specified in 'On_Off/On_Off/In1' is invalid. Port numbers must be positive integer
constants less than or equal to 65535.
Thanks for help in advance !

답변 (1개)

Pruthvi G
Pruthvi G 2019년 4월 3일
Use below code to Get what ever Output you wanted. If any further clarification needed ping me.
% Rename an inport and outport of Subsystem
link_NameValue = 'On_Off';
link_SourceNameValue = 'New Subsystem';
link_TargetNameValue = 'Subsystem Pruthvi';
new_system(link_NameValue);
open_system(link_NameValue)
add_block('simulink/Ports & Subsystems/Subsystem',[link_NameValue '/' link_NameValue]);
set_param(gcb,'Description',sprintf('%s ==> %s', link_SourceNameValue, link_TargetNameValue));
link_SourcePortNameValue = '1'; % Port number should be in Char.
Inport_name = 'Lucas_S';
set_param('On_Off/On_Off/In1','port',link_SourcePortNameValue); % Setting Port Number
set_param('On_Off/On_Off/In1','Name',Inport_name); % Stting Port Name

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by