MATLAB CODE:
clc;
clear;
close all;
%% PHASE CURRENT INPUTS (kA)
mag_Ia = 0.614; ang_Ia =-85.38; % Phase A
mag_Ib = 0.614; ang_Ib =-205.38; % Phase B
mag_Ic = 0.614; ang_Ic =34.62; % Phase C
%% PHASE VOLTAGE INPUTS (kV)
mag_Va = 0; ang_Va =0; % Phase A
mag_Vb = 0; ang_Vb = 0; % Phase B
mag_Vc =0 ; ang_Vc = 0; % Phase C
%% Convert to complex phasors
Ia = mag_Ia * exp(1i * deg2rad(ang_Ia));
Ib = mag_Ib * exp(1i * deg2rad(ang_Ib));
Ic = mag_Ic * exp(1i * deg2rad(ang_Ic));
Va = mag_Va * exp(1i * deg2rad(ang_Va));
Vb = mag_Vb * exp(1i * deg2rad(ang_Vb));
Vc = mag_Vc * exp(1i * deg2rad(ang_Vc));
%% Symmetrical Component Transformation Matrix
a = exp(1i*2*pi/3);
E = [1 1 1;
1 a^2 a;
1 a a^2];
%% Calculate Sequence Components (Original MATLAB convention)
I_seq_raw = (1/3) * E * [Ia; Ib; Ic];
V_seq_raw = (1/3) * E * [Va; Vb; Vc];
%% Rearranged to Match ETAP Labeling
I0 = I_seq_raw(1);
I1 = I_seq_raw(3); % Positive (ETAP)
I2 = I_seq_raw(2); % Negative (ETAP)
V0 = V_seq_raw(1);
V1 = V_seq_raw(3); % Positive (ETAP)
V2 = V_seq_raw(2); % Negative (ETAP)
%% Display Sequence Component Results (in ETAP naming)
fprintf('\nSymmetrical Component Currents (kA):\n');
fprintf('I0 (Zero) = %.4f %.2f°\n', abs(I0), rad2deg(angle(I0)));
fprintf('I1 (Positive) = %.4f %.2f°\n', abs(I1), rad2deg(angle(I1)));
fprintf('I2 (Negative) = %.4f %.2f°\n', abs(I2), rad2deg(angle(I2)));
fprintf('\nSymmetrical Component Voltages (kV):\n');
fprintf('V0 (Zero) = %.4f %.2f°\n', abs(V0), rad2deg(angle(V0)));
fprintf('V1 (Positive) = %.4f %.2f°\n', abs(V1), rad2deg(angle(V1)));
fprintf('V2 (Negative) = %.4f %.2f°\n', abs(V2), rad2deg(angle(V2)));
%% Create Table for Easy Matching
ComponentLabels = {'Zero Seq (0)'; 'Positive Seq (1)'; 'Negative Seq (2)'};
Currents = [I0; I1; I2];
Voltages = [V0; V1; V2];
T = table(abs(Currents), rad2deg(angle(Currents)), abs(Voltages), rad2deg(angle(Voltages)), ...
'VariableNames', {'I_Magnitude_kA', 'I_Angle_deg', 'V_Magnitude_kV', 'V_Angle_deg'}, ...
'RowNames', ComponentLabels);
disp(' ');
disp('Comparison Table (ETAP-Compatible Labels):');
disp(T);
% --- 1. Phase Currents (Ia, Ib, Ic) ---
figure;
hold on;
quiver(0, 0, real(Ia), imag(Ia), 0, 'r', 'LineWidth', 2);
quiver(0, 0, real(Ib), imag(Ib), 0, 'g', 'LineWidth', 2);
quiver(0, 0, real(Ic), imag(Ic), 0, 'b', 'LineWidth', 2);
axis equal; grid on;
title('Phasor Diagram of Phase Currents');
legend('Ia', 'Ib', 'Ic', 'Location', 'best');
xlabel('Real'); ylabel('Imag');
% --- 2. Phase Voltages (Va, Vb, Vc) ---
figure;
hold on;
quiver(0, 0, real(Va), imag(Va), 0, 'r', 'LineWidth', 2);
quiver(0, 0, real(Vb), imag(Vb), 0, 'g', 'LineWidth', 2);
quiver(0, 0, real(Vc), imag(Vc), 0, 'b', 'LineWidth', 2);
axis equal; grid on;
title('Phasor Diagram of Phase Voltages');
legend('Va', 'Vb', 'Vc', 'Location', 'best');
xlabel('Real'); ylabel('Imag');
% --- 3. Sequence Currents (I0, I1, I2) ---
figure;
hold on;
quiver(0, 0, real(I0), imag(I0), 0, 'r', 'LineWidth', 2);
quiver(0, 0, real(I1), imag(I1), 0, 'g', 'LineWidth', 2);
quiver(0, 0, real(I2), imag(I2), 0, 'b', 'LineWidth', 2);
axis equal; grid on;
title('Phasor Diagram of Sequence Currents');
legend('I0 (Zero)', 'I1 (Positive)', 'I2 (Negative)', 'Location', 'best');
xlabel('Real'); ylabel('Imag');
% --- 4. Sequence Voltages (V0, V1, V2) ---
figure;
hold on;
quiver(0, 0, real(V0), imag(V0), 0, 'r', 'LineWidth', 2);
quiver(0, 0, real(V1), imag(V1), 0, 'g', 'LineWidth', 2);
quiver(0, 0, real(V2), imag(V2), 0, 'b', 'LineWidth', 2);
axis equal; grid on;
title('Phasor Diagram of Sequence Voltages');
legend('V0 (Zero)', 'V1 (Positive)', 'V2 (Negative)', 'Location', 'best');
xlabel('Real'); ylabel('Imag');