Add one port to a Simulink block, from command line AND automaticaly keep the same distance between ports
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I'm trying to automate the creation of a Simulink model.
In some case I have to add sevral inport to BusCreators. The trouble is when I add an inport, using
get_param(buscreator_handle, 'Input', '15')
, while there were 13 inports before. The block keep the same size, but vertical distance between inports reduces...
Is there a quick way to automaticaly set block postion so that vertical distance between ports stay the same? Or does anyone know a simple computation to find 'Position' of block so that vertical distance between inports stay the same.
It's not just proportinal because I remember times ago I met BusCreator where first and last inports where exactly at top of and bottom of BusCreator, and sometimes not (gap between block top and first inport, and gap beetween last inport and block bottom).
0 个评论
采纳的回答
Fangjun Jiang
2021-2-11
I dealt with this problem before. There is no quick or automatic way but the following method worked for me to keep the existing signal lines straight.
You can get and set the position of the block, which in effect is to control the height of the block. Make
BlockHeight=a+b*n, where a is the offset, b is the linear scale, n is the number of ports you just set for the BusCreator block. You just need to play with a and b to keep the port distance the same. You might also need to play with the corner position of the block to keep the existing signal lines straight.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!