Rename an inport and outport of Subsystem
30 views (last 30 days)
Show older comments
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 !
0 Comments
Answers (1)
Pruthvi G
on 3 Apr 2019
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
0 Comments
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!