MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi
Learn moreOpportunities for recent engineering grads.
Apply TodayMATLAB Central > MATLAB Newsreader > Bernoulli random variables 

Hello, I'm fairly new to programming with Matlab and was wondering if somebody could assist me write a small code concerning Bernoulli random variables. 
Subject: Bernoulli random variables From: Nasser Abbasi Date: 29 Mar, 2009 01:55:21 Message: 2 of 11 

I've been able to make the bernoulli random variables using the rand function. However, I am having trouble trying to completely vectorize my program. It is awfully slow when I try to do 1 million simulations. 
"Bert Ji" <bert.ji@gmail.com> wrote in message <gqnl9h$9s7$1@fred.mathworks.com>... 
bernoulli(p,n,m) returns a matrix of size n x m with bernoulli random variables of probability p. 
"Bert Ji" <bert.ji@gmail.com> wrote in message <gqnl9h$9s7$1@fred.mathworks.com>... 
Do you think there is something I can do with respect to the for loop for c=1:simulations? 
"Bert Ji" <bert.ji@gmail.com> wrote in message <gqntv2$l4s$1@fred.mathworks.com>... 
Bert Ji wrote: 
I see, I have allocated N earlier in the code. 
"Bert Ji" <bert.ji@gmail.com> wrote in message <gqo0fl$ofg$1@fred.mathworks.com>... 
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.