Automatically connecting the simevents blocks

2 次查看(过去 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.

回答(1 个)

ag
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!

类别

Help CenterFile Exchange 中查找有关 Discrete-Event Simulation 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by