22 views (last 30 days)

Hy everyone, I need to compute a time series of stock price assuming that they are driven by a random walk. What would be the best way to approach the problem, i.e. the right function to do so? I should replicate it 10.000 times (N=10.000).

thanks for the help.

Rick Rosson
on 8 Mar 2016

Edited: Rick Rosson
on 8 Mar 2016

Here is some code to get you started:

N = 10000;

P = nan(N,1);

P(1) = ...

for k = 2:N

P(k) = P(k-1) + ...

end

figure;

plot(P);

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 4 Comments

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/272173-simulate-a-time-series-of-stock-price-using-monte-carlo-simulations#comment_348826

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/272173-simulate-a-time-series-of-stock-price-using-monte-carlo-simulations#comment_348826

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/272173-simulate-a-time-series-of-stock-price-using-monte-carlo-simulations#comment_348829

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/272173-simulate-a-time-series-of-stock-price-using-monte-carlo-simulations#comment_348829

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/272173-simulate-a-time-series-of-stock-price-using-monte-carlo-simulations#comment_348839

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/272173-simulate-a-time-series-of-stock-price-using-monte-carlo-simulations#comment_348839

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/272173-simulate-a-time-series-of-stock-price-using-monte-carlo-simulations#comment_348856

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/272173-simulate-a-time-series-of-stock-price-using-monte-carlo-simulations#comment_348856

Sign in to comment.