//tp4
n=50000;

function [z]=dimun(t);
  z=grand(1,1,'bin',1,0.5)*2-1;
endfunction

function [z]=dimdeux(t)
 z=[0 0];
 z(1,1+grand(1,1,'bin',1,0.5))=dimun(1);
endfunction

//dessin en dimension 1
j=[0];
u=[0];
for i=1:n
  j=[j i];
  x=u(1,i);
  u=[u x+dimun(1)]; //concaténation de matrice
end,
xset('window',0);
xbasc();
plot(j,u);


//dessin en dimension 2
xset('window',1);
xbasc();
u=[0;0];
for i=1:n
  x=u(:,i); //extraction de la i-ème colonne
  y=x+dimdeux(1)';
  u=[u y];
  //plot([u(1,i) u(1,i+1)],[u(2,i) u(2,i+1)],'red');
end;
plot(u(1,:),u(2,:),'red');
  
