- https://in.mathworks.com/help/simulink/slref/add_line.html
- https://in.mathworks.com/help/simulink/ug/approach-modeling-programmatically.html#:~:text=add%20lines%20to%20connect%20all%20the%20blocks%20in%20the%20model
Automatically connecting the simevents blocks
1 次查看(过去 30 天)
显示 更早的评论
I have an excel file as input for the matlab script. According to the excel file the blocks are generated automatically. I am facing issues with connecting the blocks. Because there might be sometimes parallel machines, so from one machine, the entities can pass to next three parallel machines. The excel file can be changed by the user according to requirement.
The blocks look like this:
The code should be flexible that if the user changes information in excel file then it should connect accordingly.
The blockas using simevents library are added in simulink model automatically. and that is working well according to my matlab script. but not able to connect the blocks accoridng to excel info. Wherever 'P' stands it connects to the previous 'S'.
I have attached the excel file and mtlab file here.
0 个评论
回答(1 个)
ag
2024-1-30
编辑:ag
2024-1-30
Hi Andanu,
To connect two blocks in Simulink, using MATLAB script, you can use the "add_line" function.
The "add_line" function takes "modelName", and "out" and "in" coordinates. You can either get the required co-ordinates from your excel file, or by using the "get_param" function.
The code snippet below, demonstrates how to connect "Source" and "Machine1" blocks generated by your MATLAB script,
out = get_param('Simevents_Model_01/Source','PortConnectivity').Position;
in = get_param('Simevents_Model_01/Machine1','PortConnectivity').Position;
add_line(Sys, [out ; in]);
You can modify the above logic accordingly, to connect the required blocks as per the data present in the excel file.
For more details, please refer to the following MATLAB documentations,
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Discrete-Event Simulation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!