function [] = RW(n)

S = zeros([n,1]);
M = zeros([n,1]);
T = zeros([n,1]);

for i = 1:n-1
   
    
    r = rand;
    if r > 1/2
        S(i+1) = S(i) + 1;
    else
        S(i+1) = S(i) - 1;
    end
    
    M(i+1) = S(i+1)^2 - (i+1);
    T(i+1) = T(i) + 1;
    
end

figure
plot(T,M,T,S)
legend('M_n','S_n')

figure
plot(T,S)
legend('S_n')

