clc, clear all, close all
fs = 1E5;
t2 = 1/fs;
time = 0:t2:0.02;
f = 50;
last = length(time);
%Graph for Three-phase Sinusoidal Waves
a = 0.8*sin(2*pi*f*time);
b = 0.8*sin((2*pi*f*time)+(120*pi/180));
c = 0.8*sin((2*pi*f*time)+(240*pi/180));
figure(1)
plot(time, a)
hold on
plot(time, b)
hold on
plot(time, c)
grid on
title(‘Three-phase Sinusoidal Waves’)
vec = zeros([1,last]);
MOS1 = vec;
MOS2 = vec;
MOS3 = vec;
MOS4 = vec;
MOS5 = vec;
MOS6 = vec;
for v = 1:last
calc = a(v) – b(v);
calc2 = a(v) – c(v);
calc3 = b(v) – c(v);
if calc > 0
if calc2 > 0
MOS1(v) = 1;
if calc3 > 0
MOS2(v) = -1;
elseif calc3 < 0
MOS6(v) = -1;
end
elseif calc2 < 0
MOS5(v) = 1;
MOS6(v) = -1;
end
elseif calc < 0
if calc2 > 0
MOS3(v) = 1;
MOS2(v) = -1;
elseif calc2 < 0
MOS4(v) = -1;
if calc3 > 0
MOS3(v) = 1;
elseif calc3 < 0
MOS5(v) = 1;
end
end
end
end
figure(2)
plot(time, MOS1)
hold on
plot(time, MOS2)
hold on
plot(time, MOS3)
hold on
plot(time, MOS4)
hold on
plot(time, MOS5)
hold on
plot(time, MOS6)
grid on