MATLAB Answers


random walk in matlab without the econometrics toolbox

Asked by Locks
on 2 May 2013


I am looking for a way to create a random walk in matlab without having the financial toolbox



No products are associated with this question.

1 Answer

Answer by Shashank Prasanna
on 2 May 2013
 Accepted answer


Note that this is based on a FOR loop .. so you might want to implement your own algorithm based on a random vector and CUMSUM if it is too slow.

 n = 200 ;  m = 20 ;  
 figure ;  hold on ;  
 for k = 1 : m
    plot(cumsum((rand(1, n) > 0.5) - 0.5), 'Color', rand(1, 3)) ;

I will try that, thank you very much for the support

Join the 15-year community celebration.

Play games and win prizes!

Learn more
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!