Function L
\begin{lstlisting}[
frame=single,
style=Matlab-Pyglike]
function L = fcn(sigma)

Lls = 3.05e-3;
Lm = 106.1e-3;
Llr = 3.053e-3;

lss = Lls + (2/3)*Lm;
lsm = -(1/3)*Lm;
lrr = Llr + (2/3)*Lm;
lrm = -(1/3)*Lm;
lsrm = (2/3)*Lm;

l1 = lsrm*cos(sigma);
l2 = lsrm*cos(sigma + 2*pi/3);
l3 = lsrm*cos(sigma + 4*pi/3);

Lss = [lss, lsm, lsm;
    lsm, lss, lsm;
    lsm, lsm, lss];

Lrr = [lrr, lrm, lrm;
    lrm, lrr, lrm;
    lrm, lrm, lrr];

Lsr = [l1, l2, l3;
       l3, l1, l2;
       l2, l3, l1];

Lrs = Lsr';

L = [Lss, Lsr;
    Lrs, Lrr];
\end{lstlisting}

Function $L^{-1}$
\begin{lstlisting}[
frame=single,
style=Matlab-Pyglike]
    function invL = fcn(L)

invL = inv(L);
\end{lstlisting}

Function dL
\begin{lstlisting}[
frame=single,
style=Matlab-Pyglike]
    function dL = fcn(sigma)

Lm = 106.1e-3;
lsrm = (2/3)*Lm;

dl1 = -lsrm*sin(sigma);
dl2 = -lsrm*sin(sigma + 2*pi/3);
dl3 = -lsrm*sin(sigma + 4*pi/3);

dLsr = [dl1, dl2, dl3;
    dl3, dl1, dl2;
    dl2, dl3, dl1];

dLrs = dLsr';

dL = [zeros(3,3), dLsr;
    dLrs, zeros(3,3)];
\end{lstlisting}

Matlab Figure Generator
\begin{lstlisting}[
frame=single,
style=Matlab-Pyglike]
mkdir figs

time = out.V_ABC.Time;
V_abc = out.V_ABC.Data;
size(time)
size(V_abc)
V_abc = squeeze(V_abc);
V_abc = V_abc.';
%-----------------------------------------------------------------
figure(1)
subplot(3,1,1);
plot(time, V_abc(:,1));
xlabel('Time (s)');
ylabel('V_A (V)');
title('Phase A Voltage');
grid on;
subplot(3,1,2);
plot(time, V_abc(:,2));
xlabel('Time (s)');
ylabel('V_B (V)');
title('Phase B Voltage');
grid on;
subplot(3,1,3);
plot(time, V_abc(:,3));
xlabel('Time (s)');
ylabel('V_C (V)');
title('Phase C Voltage');
grid on;
saveas (gcf,'figs/phase_voltage.png')
v_LL = out.V_LL.Data;
size(v_LL);
v_LL = squeeze(v_LL);
v_LL = v_LL.';
%-----------------------------------------------------------------
figure(2)
subplot(3,1,1);
plot(time, v_LL(:,1));
xlabel('Time (s)');
ylabel('V-AB (V)');
title('Vab L-L');
grid on;
subplot(3,1,2);
plot(time, v_LL(:,2));
xlabel('Time (s)');
ylabel('V-AB (V)');
title('Vac L-L');
grid on;
subplot(3,1,3);
plot(time, v_LL(:,3));
xlabel('Time (s)');
ylabel('V-BC (V)');
title('Vbc L-L');
grid on;
saveas (gcf,'figs/L-L voltage.png')
IABC = out.iABC.Data;
size(IABC);
IABC = squeeze(IABC);
IABC = IABC.';
%-----------------------------------------------------------------
figure(3)
subplot(3,1,1);
plot(time, IABC(:,1));
xlabel('Time (s)');
ylabel('iA (A)');
title('Stator phase current A');
grid on;
subplot(3,1,2);
plot(time, IABC(:,2));
xlabel('Time (s)');
ylabel('iB (A)');
title('Stator phase current B');
grid on;
subplot(3,1,3);
plot(time, IABC(:,3));
xlabel('Time (s)');
ylabel('iC (A)');
title('Stator phase current C');
grid on;
saveas (gcf,'figs/Phase_currents.png')
TEM = out.TEM.Data;
TEM = squeeze(TEM);
%-----------------------------------------------------------------
figure(4)
plot(time, TEM);
xlabel('Time (s)');
ylabel('Torque (N/M)');
title('Developed Torque');
grid on;
saveas (gcf,'figs/developed_torque.png')
\end{lstlisting}