
% plot 3-D random walk

n=100000;
x=2*round(rand(1,n))-1;
y=2*round(rand(1,n))-1;
z=2*round(rand(1,n))-1;
figure 
hold on
grid on
title('3-dimensional random walk');
axis equal
plot3(cumsum(x),cumsum(y),cumsum(z));
figure 
hold on
grid on
title('Plot of absolute value of random walk')
plot(sqrt(cumsum(x).^2+cumsum(y).^2+cumsum(z).^2))
