Positioning Subsystem Ports in Simulink/Simscape via MATLAB Code (LConn / RConn)
25 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Sayan
2024 年 5 月 29 日
編集済み: Sayan
2024 年 5 月 29 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Troubleshooting についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!