Using binornd function - problem with draw variability

Hi, I have a problem with the binornd function in simulink. I use it:
v=binornd(1,p)
'p' is variable from 0 to 1, forming on a curve (the same curve in each simulation) (the attached screen - probability; the 1st graph).
Below (2nd graph in attached screen) it is the result of the draw, with time step 0.01 sec. It is the same result for each time.
I wish that this distribution will be varies in accordance with the pseudo-random nature of the function binornd.
Do you know how to set this function, that for every time changed the results of the draw?
(It seems as grain was always the same - in r programm I can change it, but in matlab i don't know)
Regards, Sz.

Answers (1)

By writing “binornd(1,p)” you are restricting yourself to the values 0 and 1 with probabilities 1-p and p. To get a larger range use “binornd(n,p)” which will have a range of 0 to n. See:
http://www.mathworks.com/help/stats/binornd.html

2 Comments

Thank you very much for answer. Maybe I not precisely asked a question.
The fact that I have two values from binornd: 0 and 1 is OKAY.
The problem is that during the 20 seconds simulation with the same probability in exactly the same moments simulation are drawn the '1'.
So, for example each simulation have a '1' at the 0.52 s. 0.83 s. and so on, so on. Each simulation have exactly the same moments drawn '1'.
For a pseudo-random nature of the function this moments should be different.
I do not know how to activate it. Seed is responsible for this. In matlab works OK. But in simulink - no.
It sounds to me as if you are resetting the seed each time to the same value. That is exactly what you DON’T want to do. Either use something like rng('shuffle') or leave it alone. Read the description at:
http://www.mathworks.com/help/matlab/ref/rng.html

Sign in to comment.

Tags

Asked:

on 16 May 2016

Commented:

on 17 May 2016

Community Treasure Hunt

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

Start Hunting!