%% Calculate Voltage Derivatives for a Specific Time Period


% 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');
%% 
% The model simulation time is 1.25e-4 seconds. Calculate and display 
% rates-of-change of voltage variables for the Transformer block during 
% the last 0.25e-4 seconds of the simulation. Use a time step of 1e-9 
% seconds.
transformerTable = ee_getNodeDvDtTimeSeries(simlog_ee_converter_dcdc_class_e.Transformer,1e-9,1e-4)
%%
% The table contains time series data of voltage variables, and their first 
% derivatives, for the Transformer block over the last 0.25e-4 seconds of 
% the simulation. The table does not list terminals that are held fixed 
% to the ground.
%
% View the time series data. From the workspace, open the |transformerTable|  
% table, then open the two |1x25001 double| numeric arrays for the 
% |Transformer.p1|.
%
% The first array contains the voltage data. The second array contains the 
% voltage derivative data.
% 
% Plot the data.
time = 1e-4:1e-9:1.25e-4;
vOut = transformerTable.Voltage{1};
dvdtOut = transformerTable.dvdt{1};
 
ax1 = subplot(2,1,1);
plot(time,vOut),grid;
ylabel('Voltage (V)');
ax1.YLim = [-1000 1500];
ax1.XTickLabel = {};
ax1.Title.String = 'Transformer Primary Voltage';
 
ax2 = subplot(2,1,2);
plot(time,dvdtOut),grid;
ylabel('Voltage Derivative (V/s)');
xlabel('Time (s)');
ax2.Title.String = 'Transformer Primary Voltage Derivative';
%%

