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.
  27 Comments
Aftab Ahmed Khan
Aftab Ahmed Khan on 12 Jun 2014
Hi, I just managed what i wanted to achieve. Thank you so much dear. i really appreciate your time and support. Take care......
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.
Cheers.

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.
  3 Comments
Aftab Ahmed Khan
Aftab Ahmed Khan on 11 Jun 2014
Hello, i have tried up to this point but how can i introduce the departure time with it.
for i =1:10
timenow = event_arrivals(i);
no_channels = find(BS_channeltable == 0);
first_available = min(no_channels);
if timenow == (event_arrivals(i))&& (first_available ~=0)
BS_channeltable(first_available)=1;
end
end
Please help me with it.
Aftab Ahmed Khan
Aftab Ahmed Khan on 11 Jun 2014
Edited: Aftab Ahmed Khan on 11 Jun 2014
Hi,
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');
end
end
and how can i get my simulation to the departure time?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!