How to obtain the source and destination block names and port numbers connected by a signal in Simulink?
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 23 Jan. 2019
Beantwortet: MathWorks Support Team
am 27 Mär. 2019
If I click on a certain signal in a Simulink model, how can I programmatically obtain the names of the source and destination blocks connected by the signal? Also, how can the port numbers (source and destination) be printed from the Command Window?
Akzeptierte Antwort
MathWorks Support Team
am 23 Jan. 2019
The handle to a selected signal can be obtained using the 'find_system' command:
>> h_line = find_system(gcs,'FindAll','on','FollowLinks','on','type','line','Selected', 'on');
The names of the source and destination blocks with respect to the selected signal can be obtained using the 'get_param' command with the 'SrcBlockHandle' and 'DstBlockHandle' parameters:
>> source_block_handle = get_param(h_line, 'SrcBlockHandle');
>> source_block_name = get_param(source_block_handle, 'Name');
Similarly, the 'SrcPortHandle' and 'DstPortHandle' parameters can be used to obtain the port numbers associated with the selected signal:
>> source_port_handle = get_param(h_line, 'SrcPortHandle');
>> source_port_number = get_param(source_port_handle, 'PortNumber');
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Prepare Model Inputs and Outputs finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!