%% Calculate Voltage Derivatives by Block for the Whole Model

% Copyright 2018 The MathWorks, Inc.

%%
% Open the Class E DC-DC Converter example model.
open_system('ee_converter_dcdc_class_e')
%%
% This example model has data logging enabled. Run the simulation to create
% the simulation log variable |simlog_ee_converter_dcdc_class_e| in your 
% current workspace.
sim('ee_converter_dcdc_class_e');
%% 
% Calculate rates-of-change of voltage variables for the whole model with 
% a time step of 1e-9 seconds, and return the time series data in a table.
seriesTable = ee_getNodeDvDtTimeSeries(simlog_ee_converter_dcdc_class_e,1e-9)
%%
% The table contains time series data of voltage variables and their first 
% derivatives over the whole simulation time for all the blocks in the model 
% that have nodes based on the |foundation.electrical.electrical| domain.
%
% View the time series data. From the workspace, open the |seriesTable| table, 
% then open the two |1x125001 double| numeric arrays for the 
% |ee_converter_dcdc_class_e.LDMOS.D|.
%
% The first array contains the voltage data. The second array contains the 
% voltage derivative data.
% 
% Plot the data.

time = 0:1e-9:1.25e-4;
vOut = seriesTable.Voltage{6};
dvdtOut = seriesTable.dvdt{6};
 
ax1 = subplot(2,1,1);
plot(time,vOut),grid;
ylabel('Voltage (V)');
axis([0 1.25e-4 0 1000]);
ax1.XTickLabel = {};
ax1.Title.String = 'LDMOS Stress Voltage';
 
ax2 = subplot(2,1,2);
plot(time,dvdtOut),grid;
ylabel('Voltage Derivative (V/s)');
xlabel('Time (s)');
axis([0 1.25e-4 0 4e10]);
ax2.Title.String = 'LDMOS Stress Voltage Derivative';
%%