How to control a Release Gate with data computed in another Subsystem?

3 views (last 30 days)
Hello everyone,
I am trying to do a traffic simulation with SimEvents (Matlab R2013b). Since I have cars, that change their data continuously and entities, which are in a discrete event system I have to synchronize both parts. For a straight street my approach was to store the entities in a N-Server until the car has passed the straight and then let it out. The data of the car is stored in a matrix and each car has its own ID. Now the SimEvents system needs to check in the Matrix if the car already passed and then needs to open the release gate. If I try implementing this the function, which reads the memory matrix, is just executed once and the I also tried using "Event To Timed Signale" Blocks before and after the function, which reads the memory. But then I get an algebraic loop error. If I break this loop with an delay, my data gets too old, which falsifies my simulation. Do you have any ideas how to solve this? Is there a possibility to tell Simulink, to execute this function continuously?
Thanks for your help. I attached an example code.

Accepted Answer

Sandip Kumar
Sandip Kumar on 27 Oct 2014
Based on the example model you had, I have modified the model to incorporate a 'Data Store Read' block, to read the Matrix (which is getting modified every time step).
If you attach a scope to output of MATLAB function block, ControlReleaseGate/Straight/Scope you will notice the MATLAB function is actually reading the modified values.
Now you will notice, although there are 5 entities in the N-server, the release gate is not releasing them, because the setting on release gate says to only open gate when the "change in signal from port VC".
Please find the attached model here, usage of Data Store Read block fixes the issue you were noticing.
Thank Sandip

More Answers (0)


Find more on Discrete-Event Simulation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by