function dotq = pendulum_Cartesian (t, q)
% ’P�U‚èŽq�iƒfƒJƒ‹ƒg�À•WŒn�j‚Ì‰^“®•û’öŽ®
    global len;
    global mass;
    global grav;
    global nu;

    x = q(1); y = q(2);
    vx = q(3); vy = q(4);

    R = sqrt(x*x + (y-len)*(y-len)) - len;

    P = 1/sqrt(x*x + (y-len)*(y-len));
    Rx = x*P; Ry = (y-len)*P;
    Rxx = P - x^2*P^3; Ryy = P - (y-len)^2*P^3; Rxy = -x*(y-len)*P^3;
    C = Rxx*vx*vx + Ryy*vy*vy + 2*Rxy*vx*vy + 2*nu*(Rx*vx + Ry*vy) + nu*nu*R;
    A = [ mass, 0, -Rx;...
          0, mass, -Ry;...
          -Rx, -Ry,  0 ];
      b = [ 0; -mass*grav; C ];
      d = A\b;
      dotvx = d(1); dotvy = d(2);

      dotq = [vx; vy; dotvx; dotvy];
end
