% global Ron Goff % % Set initial conditions % tf = 0.05; dt = tf/100; t = 0:dt:tf; tol = 1e-5; % % The current through the inductor serves as continuous state % uR0 = 0; i00 = 0; xc0 = [uR0;i00]; % % There is one discrete state variable: % % m0 = 1 (true) : diode is blocking % 0 (false) : diode is conducting % m0 = 0; xd0 = m0; % % Simulate using RKF4/5 with root solver % Ron = 1e-4; Goff = 1e-4; echo off % % Repeat the simulation with different fudge values % Ron = 1e-5; Goff = 1e-5; echo off % % Plot the results % subplot(2,1,1) plot(tout1,y1(1,:),tout2,y2(1,:)) grid on title('Homework [H9.14]') xlabel('Time') ylabel('uC') subplot(2,1,2) plot(tout1,y1(2,:),tout2,y2(2,:)) grid on xlabel('Time') ylabel('h') % print -deps nsds_hw9_14.eps diary off