function [fdx,fcross,fev,fevini]=pelotitaev2d()
  function dx=fdx(x,t,d)
    m=1;
    k=1e6;
    b=30;
    g=9.8;

    dx=x;
    dx(1)=x(2);
    dx(2)=-g-d(1)*(b/m*x(2)+k/m*x(1))
    dx(3)=x(4);
    dx(4)=0-d(2)*(b/m*x(4)+k/m*x(3));
  endfunction

  function fcr=fcross(x,t,d,ind)
    select ind
      case 1 then
        fcr=x(1),
      case 2 then
        fcr=x(3),
      else 
       fcr=[x(1);x(3)];
    end
  endfunction
  
  function dnew=fev(x,t,d,ind)
     dnew=d;
     dnew(ind)=1-d(ind)
  endfunction

  function dnew=fevini(x,t)
    dnew=(1-sign([x(1)+%eps;x(3)+%eps]))/2
  endfunction
  
endfunction

  
