% % Perform first the simulation of homework problem [H9.14] % % nsds_hw9_14 % % Now we perform the new simulation % Set initial conditions % tf = 0.05; dt = tf/100; t = 0:dt:tf; tol = 1e-5; % uR0 = 0; xc0 = uR0; % % There is one discrete state variable: % % m0 = 1 (true) : diode is blocking % 0 (false) : diode is conducting % % The current through the inductor serves as discrete state % i00 = 0; m0 = 0; xd0 = [i00;m0]; % % Simulate using RKF4/5 with root solver % echo off % % Plot the results % subplot(2,1,1) plot(tout2,y2(1,:),tout3,y3(1,:)) grid on title('Homework [H9.15]') xlabel('Time') ylabel('uC') subplot(2,1,2) plot(tout2,y2(2,:),tout3,y3(2,:)) grid on xlabel('Time') ylabel('h') % print -deps nsds_hw9_15.eps diary off