Tend = 30; u0 = [0;0];

function curr = Diode(u)
  Rd = 10; us = 0.7;
  if (u>=-us)  curr=0;
  else curr=Rd*(u+us);
  endif
endfunction

function y = circuit(u,t)
  C1 = 1; C2 = 1;
  y  = [-1/C1*(Diode(u(1)-10*sin(t))-Diode(u(2)-u(1)));
        10*cos(t)-1/C2*Diode(u(2)-u(1))];
endfunction


t = linspace(0,Tend,100);
lsode_options("absolute tolerance",1e-5);
lsode_options("relative tolerance",1e-5);

t0 = cputime();
u = lsode('circuit',u0,t);
timer = cputime()-t0
plot(t,u(:,2))
grid on; xlabel('time'); ylabel('tension');


