Automatically connecting the simevents blocks

1 Ansicht (letzte 30 Tage)
Andanu Vidya Sagar Patro
Andanu Vidya Sagar Patro am 26 Mär. 2022
Bearbeitet: ag am 30 Jan. 2024
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.

Antworten (1)

ag
ag am 30 Jan. 2024
Bearbeitet: ag am 30 Jan. 2024
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!

Kategorien

Mehr zu Discrete-Event Simulation finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by