make a serie of repeating elements

3 views (last 30 days)
Hallo everyone
I'm trying to make a transmission line for my project in simulink.
I need to connect a big number of elements in serie without copying the element many times and connect then individually.
you can see the element in the attached picture.
thank you in advanced for your answers

Accepted Answer

Pavan Guntha
Pavan Guntha on 20 Oct 2021
Hello Mohammad,
In order to automate the task of connecting large number of elements in Simulink you could leverage 'Programmatic Modeling Basics' documentation page which describes about instantiating and connecting multiple Simulink blocks using MATLAB commands. The following example illustrates this approach:
1) Instantiate and connect the elements which we want to repeat in the Simulink model:
2) Enclose this within a subsystem (Keyboard Shortcut Ctrl + G):
3) Then you could use the MATLAB commands as illustrated in the documentation page linked above to instantiate this Subsystem again and connect these 2 subsystems as follows:
load_system('repeat_elements') % Simulink Model Name is repeat_elements
add_block('repeat_elements/Subsystem','repeat_elements/Subsystem1'); % Instantiating a copy of this Subsystem
% Connecting these subsystems:
add_line('repeat_elements', 'Subsystem/RConn1', 'Subsystem1/LConn1') % For Simscape blocks, RConn1 - Output Port 1, LConn1 - Input Port 1
add_line('repeat_elements', 'Subsystem1/RConn1', 'Subsystem/LConn1')
The model is as follows after running these commands:
You could also leverage looping constructs to automate the process of instantiating the subsystems and connect them as per the requirement.
Hope this helps!

More Answers (0)

Categories

Find more on Simulink Environment Customization in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!