Clear Filters
Clear Filters

Is there a way to generate unique random number in Simevents?

2 views (last 30 days)
I am currently working with Queueing Network model using Simevents. Each server has service time, and I am using rand and randn to generate random service time for each server (for ex, -1 * 0.22 * log(1 - rand()) + 0.13 or 0.3+0.1*randn). I realized that most of the entity's service time are the same. I have tried generating seed, but it's still the same service time. I have followed
these two documents, but the result are the same (I also used rng('shuffle'), but still doesn't work)
Is there a way to generate unique random number using rand() and randn() other than the methods I used in simevents? Thank you.

Answers (1)

Brahmadev on 14 Sep 2023
I understand that you would like to generate random numbers using Entity Generator. The following code as the "Intergeneration time action" should give different results on each simulation.
% coder.extrinsic is used to make sure that all interactions with the
% random number generator (RNG) and rand() are executed outside of Simulink
% You need to explicitly mention the type for the variable that is receiving values
% from a function declared as coder.extrinsic. If not, MATLAB will return value of type mxArray.
newValue = double(0);
newValue = rand();
dt = -1*0.22*log(1-rand()) + 0.13 ; % Values generated at random service time
Hope this helps!


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!