function [xdnew] = dst_eq3(xc,xd,t,evt_nbr)
%
%  Discrete event model of [H9.15]
%
global h
%
uR = xc(1);
i0 = xd(1);
m0 = xd(2);
%
if evt_nbr == +1,
  %
  %  An end-of-step event has occurred.  We need to update the inductor
  %  current
  %
  R2 = 50e3;
  L1 = 1.5e-3;
  C1 = 1e-6;
  V0 = 10;
  p = 50;
  tp = 1/p;
  %
  U0 = V0*sin(2*pi*t/tp);
  iR = uR/R2;
  s = (L1*i0 + h*(U0 - uR))/(L1*(1 - m0) + h*m0);
  uD = m0*s;
  uL = U0 - uD - uR;
  di0 = uL/L1;
  i0 = i0 + h*di0;
end
%
if evt_nbr == -1,
  %
  %  A state event has occurred.  We need to toggle the diode switch
  %
  m0 = not(m0);
end
%
xdnew = zeros(2,1);
xdnew(1) = i0;
xdnew(2) = m0;
%
return