Positioning Subsystem Ports in Simulink/Simscape via MATLAB Code (LConn / RConn)
25 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Dear Community,
I'm currently working on my master's thesis and attempting to create a Simulink/Simscape model directly from MATLAB. I aim to consolidate certain "Building Blocks" that are used repeatedly into a subsystem for the sake of clarity. My goal is to position the ports of this subsystem directly from MATLAB.
Presently, I have a result that looks similar to the attached image.
However, I wish to rearrange the ports, all of which are currently situated on the left side of the subsystem, so that they are positioned as follows (Manual Post-Processing Performed):
In my attempts thus far, I've encountered the issue that the ports are set as "read-only," preventing me from defining their positions. I've tried to set the position as follows:
subsystem_block = "path_to_subsystem"
port_handles = get_param(subsystem_block, 'PortHandles')
N = length(port_handles.LConn)
newx = 1:N % example
newy = 1:N % example
for k = 1:N
set_param(port_handles.LConn(i), 'Position', [newx(k), newy(k)]);
end
Unfortunately, this yields the error message "Port parameter 'Position' is read-only."
Is there a way to set the position of the ports of the subsystem directly from MATLAB? If so, could someone explain how to do it? If not, what alternatives would I have if I still want to utilize a sort of "Building Block"?
Any assistance would be greatly appreciated!
0 Commenti
Risposte (1)
Sayan
il 29 Mag 2024
Modificato: Sayan
il 29 Mag 2024
Hi Raphael,
I too have faced the same issue. It seems the position of the ports (both Simulink ports and Physical ports) on the subsystem interface cannot be changed directly from MATLAB programmatically because the properties are read-only. Only way to do this is through Simulink.This seems to be intended behavior. However, you can change the side of the "Connection port" programmatically.
set_param('Path to your Connection port block inside subsystem','side','Right')
You can check out a similar kind of issue addressed in the following MATLAB answer.
Hope this helps.
0 Commenti
Vedere anche
Categorie
Scopri di più su Troubleshooting in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!