MATLAB Answers


Loop to generate n random series (filling a matrix?)

Asked by Javier
on 17 Apr 2013

Hi, i´m glad if you could help me with this

I have a funcion that generate a random trajectory for a variable (like a brownian motion, with a trend + a random shock normally distributed).


This function generate a vector of n/delta rows, that represent the trajectory of the variable.

What i want is to generate 1000 of this trajectories making a loop (i think i should store them as 1000 columns of a matrix)

I have used loops before, but in this case i don´t know how to do it, because what i need to do is like a loop over the random shock of the function

I don´t know if this is an easy question, buy i am a begginer with matlab. Thank you very much! Javier


Log in to comment.

1 Answer

Answer by Iman Ansari on 17 Apr 2013

Maybe this:

for i=1:1000

  1 Comment

I don´t know why, but that did not work.

I have solved the problem this way:

while c<=number

theta(:,c)=simGBM(n,theta0,alpha,sigma,delta); c=c+1; end


Log in to comment.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!