Rename an inport and outport of Subsystem
30 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!