make a serie of repeating elements

2 visualizaciones (últimos 30 días)
Mohammad Shtiwi
Mohammad Shtiwi el 15 de Oct. de 2021
Comentada: Mohammad Shtiwi el 21 de Oct. de 2021
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

Respuesta aceptada

Pavan Guntha
Pavan Guntha el 20 de Oct. de 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!

Más respuestas (0)

Categorías

Más información sobre Subsystems en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by