out=sim("M5_group_v10.slx")


%%

mkdir figs

% xlims_zoom=[1.75 2];
xlims_zoom=[0 0.25];

figure(1)
plot(out.iabc)
title("Phase Currents")
ylabel("Current [A]")
legend(["phase a", "phase b", "phase c"])
saveas(gcf,'figs/currents.png')
xlim(xlims_zoom)
saveas(gcf,'figs/currents_zoom.png')


figure(2)
subplot(3,1,1)
plot(out.va)
title("Voltage phase a")
ylabel("Voltage phase a [V]")

subplot(3,1,2)
plot(out.vb)
title("Voltage phase b")
ylabel("Voltage phase b [V]")

subplot(3,1,3)
plot(out.vc)
title("Voltage phase c")
ylabel("Voltage phase c [V]")

saveas(gcf,'figs/voltages.png')
subplot(3,1,1)
xlim(xlims_zoom)
subplot(3,1,2)
xlim(xlims_zoom)
subplot(3,1,3)
xlim(xlims_zoom)
saveas(gcf,'figs/voltages_zoom.png')


figure(3)
plot(out.w)
title("Rotor Speed [rad/s]")
saveas(gcf,'figs/speed.png')
xlim(xlims_zoom)
saveas(gcf,'figs/speed_zoom.png')

figure(4)
plot(out.trq_dev)
title("Developed Torque")
saveas(gcf,'figs/torque.png')
xlim(xlims_zoom)
saveas(gcf,'figs/torque_zoom.png')

