%% Calculate Dissipated Power Losses for the Entire Simulation Time
% This example shows how to calculate instantaneous losses based on the power dissipated and return the time series data for all time steps in the entire simulation time using the ee_getPowerLossTimeSeries function.
% Open the model. At the MATLAB® command prompt, enter:

model = 'ee_solar_converter'; 
open_system(model) 

% This example model has data logging enabled. Run the simulation and create the simulation log variable.

sim(model) 

% The simulation log variable simlog_ee_solar_converter is saved in your current workspace.
% The model simulation time (t) is 1/60 seconds. Calculate dissipated power losses and return the time series data in cell array for the second half of the simulation cycle, when t is between 1/120 and 1/60 seconds.

lossesCell = ee_getPowerLossTimeSeries(simlog_ee_solar_converter)

% View the time series data. From the workspace, open the lossesCell cell array, then open the numeric array for the ee_solar_converter.Diode1.
% The first two columns contain the interval start and end time. The third column contains the power loss data.
% Plot the data.

plot(lossesCell{1, 2}(:,end))
title('Dissipated Power')
xlabel('Time Interval')
ylabel('Power (W)')

% Copyright 2018 The MathWorks, Inc.