%%%% Loss Table Calculation %%%%

clear all
close all

%% 
V_in = [350, 400, 500, 600];    %Drain-SOurce Voltage [V]
I_D = [1, 2, 3, 4, 5];          %Drain Current [A]
Qg = 62e-9;                     %Q_GS + Q_GD [C]
I_g = 1.61;                      %Average Gate current [A]
T_sw = Qg/I_g;                  %Switching time [s]
E_sw  = 1/2 * V_in' * I_D * T_sw;   %Switching losses [W] 

figure
colormap("parula")
surf(V_in, I_D, E_sw'*1e6)
xlabel("V_{DS}in V")
ylabel("I_D in A")
zlabel("E_{sw} in \mu J")
title("Switching Losses")
grid minor

E_copy = E_sw*1e6;

data = readtable("Diode_forward.csv");
figure
plot(data.x, data.y)
grid minor
xlabel("V_F in V")
ylabel("I_D in A")
title("Forwrd Characteristics Diode")
