# MATLAB Matlab: Plotting multiple paths (random walk)

#### spenghali

I have created a code to simulate a scaled random walk, but I need to now modify it to generate 1000 paths and then estimate the variance with n = 100, for t = 0.25, 0.5, 0.75 and 1. Can anyone help out with how to generate all 1000 paths? Sorry if this is painfully easy, I am a complete matlab/coding noob.

clear;
N = 10
t = (0:1:N)';
X = [0; cumsum(2*(rand(N,1)>0.5)-1)];

plot(t/N,X(1:N+1)/sqrt(N));
axis([0 1 -2 2]);
title(['Uniform Sample 1000 steps'])

ylabel('Position')
xlabel('Time')

Last edited:
Related Math Software Workshop News on Phys.org

"Matlab: Plotting multiple paths (random walk)"

### Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving