[matlab]Auto-connect block to existing line
来源:互联网 发布:网络借贷 暂行办法 编辑:程序博客网 时间:2024/06/05 23:00
Last time I did something like this,
[in1]--line--[out1]
- %find_system out1 (or the list of what I was adding to)
- get the position of out1 = pos
- get the input port to out1
- get the line handle
- get the source port (out port of in1)
- delete the line
- set_param out1 to position [pos(1)+dx pos(2) pos(3)+dx pos(4)]
- add conv block to 'pos'
- addline in1 to conv
- addline conv to out1
Side note, if the list is really long, name the blocks 'well' and do a loop at the end to add all the lines. My code, with lines added at every step, took 2-3 hours. Doing lines at the end, took 20 mins. [Might only apply to Simulink 6.6.1]
EDIT: Actually, for your specific question, have you tried (no idea if this will work).get_param the port location (x,y location)
add_line([x y], [x y]) %effectively, draw a 'dot'
or get the port location of the existing block, port location of the new block, and add_line to those
I had no idea you could just drop a block on a line to connect it, that's cool. Learn something everyday. Unfortunately, I think that might just be a GUI feature.
Can you quasi-draw out what you want to add? (I think I just got it, by infront you mean behind?) So.
[inport]--->[subsys where there are 19 other inputs]
and you want?
[inport]-->[conv]-->[subsys]
Played around, got this (step through this)
new_system('simtest')open_system('simtest')
simulink('open')%% setupadd_block('simulink/Commonly Used Blocks/In1','simtest/in1')set_param('simtest/in1','Position',[50 50 100 75])
add_block('simulink/Commonly Used Blocks/Out1','simtest/out1')set_param('simtest/out1','Position',[500 50 550 75])
add_line('simtest','in1/1','out1/1')
%% real code%find_system blah blah in1
pos1 = get_param('simtest/in1','Position');pos2 = [pos1(1)+200 pos1(2) pos1(3)+200 pos1(4)];set_param('simtest/in1','Position', pos2);%get a lot of parameters here for in1, name, port numberdelete_block('simtest/in1')
add_block('simulink/Commonly Used Blocks/Data Type Conversion','simtest/conv1')set_param('simtest/conv1','Position', pos2);%set_param('OutDataType')
add_block('simulink/Commonly Used Blocks/In1','simtest/in1')set_param('simtest/in1','Position', pos1);%set_param( name, port number)
add_line('simtest','in1/1','conv1/1')
- [matlab]Auto-connect block to existing line
- Adding an existing project to GitHub using the command line
- Adding an existing project to GitHub using the command line
- wifi command line connect to ap
- MS SQL Server - How to change an existing column to auto-increment column
- xcode checkout an existing project 出错 unable to connect to a repository at url解决方法
- How to disable WIFI Auto-connect in Android ( 附带 转载)
- 【opencv】,【matlab】How to connect Matlab with OpenCV on Windows7
- Failed to connect to /XXXfor block, add to deadNodes and continue. java.net.NoRouteToHostException:
- block,line-block,inline大小
- Docker - How to Connect to a MySQL Running Container Using MySQL Command Line Client
- error 2003: cann't connect to mysql server & MySQL Command Line Client一闪而过
- Matlab line函数
- Matlab line函数
- matlab的line函数
- How To Partition Existing Table Using DBMS_Redefinition
- Unable to determine name from existing gemspec
- Categories Add Methods to Existing Classes
- 三十而立 懵懵懂懂 是时候总结点什么了
- bzoj1041 [HAOI2008]圆上的整点
- log4j使用记录
- AVPacket与AVFrame的关系
- Oracle执行计划
- [matlab]Auto-connect block to existing line
- bzoj1192 [HNOI2006]鬼谷子的钱袋
- 反射基础
- npm安装deasync引用出错
- FastReport 导出pdf时中文乱码的解决办法
- leetcode 140. Word Break II
- bzoj1214 [HNOI2004]FTP服务器
- Java小程序之阶乘
- 数据库锁总结