我一直在尝试生成输入正弦波的正序、负序和零序分量。我有三个120度分离的正弦相位(平衡)。下面给出了正序、负序和零序的计算公式。
其中 a = 0.5 + i0.866 或 1<120* (complex number). Now if i generate Va , Vb , Vc inside of a matlab itself and use the formulae I get the correct result. Code below and correct result too .
% Define Parameters
t = 0:0.001:1; % Time vector
A = 1; % Amplitude
f = 50; % Frequency in Hz
% Generate Sinusoidal signals with 120 degrees phase shift
v_a = A * exp(1i * (2 * pi * f * t)); % V_a = A * e^(j * 0)
v_b = A * exp(1i * (2 * pi * f * t - 2 * pi / 3)); % V_b = A * e^(j * 120°)
v_c = A * exp(1i * (2 * pi * f * t + 2 * pi / 3)); % V_c = A * e^(j * -120°)
% Call the function to calculate sequence components
[va_pos, va_neg, va_zero] = fcn(v_a, v_b, v_c);
% Plotting the sequence components
figure;
% Plot for Positive Sequence Component
subplot(3,1,1);
plot(t, real(va_pos), 'r', 'DisplayName', 'Real Part');
hold on;
title('Positive Sequence Component');
xlim([0 0.3]);
ylim([-1 1]);
xlabel('Time (s)');
ylabel('Amplitude');
legend show;
grid on;
% Plot for Negative Sequence Component
subplot(3,1,2);
plot(t, real(va_neg), 'r', 'DisplayName', 'Real Part');
hold on;
%plot(t, imag(va_neg), 'b', 'DisplayName', 'Imaginary Part');
title('Negative Sequence Component');
xlabel('Time (s)');
ylim([-1 1]);
ylabel('Amplitude');
legend show;
grid on;
% Plot for Zero Sequence Component
subplot(3,1,3);
plot(t, real(va_zero), 'r', 'DisplayName', 'Real Part');
hold on;
%plot(t, imag(va_zero), 'b', 'DisplayName', 'Imaginary Part');
title('Zero Sequence Component');
xlabel('Time (s)');
ylim([-1 1]);
ylabel('Amplitude');
legend show;
grid on;
% Function to calculate sequence components
function [va_pos, va_neg, va_zero] = fcn(v_a, v_b, v_c)
% Define complex exponential for 120 degrees and 240 degrees
alpha = complex(-0.5, 0.866); % e^(j*120 degrees)
alpha_square = complex(-0.5, -0.866); % e^(j*240 degrees)
% Calculate positive sequence component
va_pos = (1/3) * (v_a + alpha * v_b + alpha_square * v_c);
% Calculate negative sequence component
va_neg = (1/3) * (v_a + alpha_square * v_b + alpha * v_c);
% Calculate zero sequence component
va_zero = (1/3) * (v_a + v_b + v_c);
end
现在我有了 Va 、 Vb 、 Vc (我现在使用正弦波模块在 simulink 中生成它们)并将它们用作下面编写的 simulink 函数的输入(与上面编写的相同)。
function [va_pos, va_neg, va_zero] = fcn(v_a, v_b, v_c)
% Define complex exponential for 120 degrees and 240 degrees
alpha = complex(-0.5,0.866); % e^(j*120 degrees)
alpha_square = complex(-0.5,-0.866); % e^(j*240 degrees)
% Calculate positive sequence component
va_pos = (1/3) * (v_a + alpha * v_b + alpha_square * v_c);
% Calculate negative sequence component
va_neg = (1/3) * (v_a + alpha_square * v_b + alpha * v_c);
% Calculate zero sequence component
va_zero = (1/3) * (v_a + v_b + v_c);
结束
它给出了错误的结果,如下所示。(第一个图是正序,第二个是负序,第三个是零序。与上面提到的图相同)。
我怀疑这是因为它实时获取 Va 、 Vb 和 Vc (在 simulink 模型中)。
我尝试使用abs()和phase()分别提取正弦波的相位和幅度(在simulink中的实时函数中)但无济于事。我想知道是否有一种方法可以像在 simulink 中一样使用 MATLAB 脚本实际提取正弦波的相位和幅度?
我无法像那些子图中那样重新创建波形的错误是我只添加了复杂正弦波形的实部。
为了提取波形,我使用了“PLL 块”(以获取频率“f”)和时钟(以获取时间值)。
那么代码如下。
function [va_pos,vb_pos,vc_pos,va_neg,vb_neg, vc_neg, va_zero,vb_zero,vc_zero,va_reconstructed,vb_reconstructed,vc_reconstructed] = fcn(t, f, va_in, vb_in, vc_in)
% Calculate the phase-shifted voltages
v_a = va_in * exp(1i * (2 * pi * f * t)); % V_a = A * e^(j * 0)
v_b = vb_in * exp(1i * (2 * pi * f * t - 2 * pi / 3)); % V_b = A * e^(j * 120°)
v_c = vc_in * exp(1i * (2 * pi * f * t + 2 * pi / 3)); % V_c = A * e^(j * -120°)
% Define complex exponential for 120 degrees and 240 degrees
alpha = exp(1i * 2 * pi / 3); % e^(j * 120 degrees)
alpha_square = exp(-1i * 2 * pi / 3); % e^(j * 240 degrees)
% Calculate positive sequence component (full complex value)
va_pos = (1/3) * (v_a + alpha * v_b + alpha_square * v_c);
vb_pos = alpha_square * va_pos;
vc_pos = alpha * va_pos;
% Calculate negative sequence component (full complex value)
va_neg = (1/3) * (v_a + alpha_square * v_b + alpha * v_c);
vb_neg = alpha * va_neg;
vc_neg = alpha_square * va_neg;
% Calculate zero sequence component (real part)
va_zero = (1/3) * (v_a + v_b + v_c);
vb_zero = va_zero;
vc_zero = va_zero;
% Reconstruct the original signal (optional)
% This can be done to check if va_in ≈ va_pos + va_neg + va_zero
va_reconstructed = va_pos + va_neg + va_zero;
vb_reconstructed = vb_pos + vb_neg + vb_zero;
vc_reconstructed = vc_pos + vc_neg + vc_zero;
结束
现在重建之后。要绘制实时值,您可以在时域中使用 real() 进行绘制。
我使用实部进行绘图,然后也使用实部进行重建(这就是错误)。
谢谢您的帮助。