make a serie of repeating elements
조회 수: 2 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Pavan Guntha
2021년 10월 20일
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!
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Subsystems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!