Event base simulation in matlab

1 view (last 30 days)
Hi, I don't know how to do event based simulation in matlab. Just need a start for it, this question is a start part of my bigger task.
i have this,
arrival_departure_frequency =
0.0000 5.9489 0
0.0000 6.6353 0
0.0001 6.9292 0
0.0001 6.9361 0
0.0001 7.2979 0
0.0001 7.7989 0
0.0002 7.9419 0
0.0002 8.8358 0
0.0002 8.8383 0
0.0002 9.0600 0
First column is my event_arrivals and the 2nd column is event_departure. I want to change the value of third column from 0 to 1 when the simulation is in between arrival time and the departure time.
Once the event_departure arrives it again back set to O. Thank you so much.
Abhishek M
Abhishek M on 13 Jun 2014
Cool.. I saw your recent query. That question seems to be more clear than this. Anyways good to know you got your solution.

Sign in to comment.

Accepted Answer

Abhishek M
Abhishek M on 11 Jun 2014
Hi Aftab, I insist you to use stateflow for this logic. You can create your events and trigger the output based on your logic.
Aftab Ahmed Khan
Aftab Ahmed Khan on 11 Jun 2014
Edited: Aftab Ahmed Khan on 11 Jun 2014
I have managed up to this point but how can i release the channel from it as it will never reach to the departure time of the files.
for i =1:10
timenow = event_arrivals(i);
no_channels = find(BS_channeltable == 0);
first_available = min(no_channels);
%%Allocating the Channel on the file arrival
if timenow == (event_arrivals(i))&&(first_available ~=0)
BS_channeltable(first_available) = 1;
fprintf(fid,'Frequency is assigned.\n');
Releasing the channel on file departure
elseif timenow == event_departures(i)
release_channel = find(BS_channeltable==1);
last_occuped = max(release_channel);
BS_channeltable(last_occuped) = 0;
fprintf(fid,'Frequency is released.\n');
and how can i get my simulation to the departure time?

Sign in to comment.

More Answers (0)


Find more on Simulink Functions 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