-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactive_power_functions.m
80 lines (49 loc) · 2.24 KB
/
active_power_functions.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
% Here is an example MATLAB function that takes an array of active power values and calculates the corresponding reactive power values assuming a power factor of 0.85 and a frequency of 50 Hz:
% ind is inductive cap is capacitive reac is reactive
p=500+(3e6-2e6).*rand(1,100)
[ind, cap] = calc_reactiver(p);
disp(ind);
disp(capr);
reactive_power = calc_reactive_power(p);
disp(reac);
function reac = calc_reactive_power(p)
% Calculates the reactive power for an array of active power values.
% Assumes a power factor of 0.85 and a frequency of 50 Hz.
% Constants for the calculation
pf = 0.85;
f = 50; % Hz
V = 10000; % V (assuming a line-to-line voltage of 10 kV)
% Calculate the apparent power for each active power value
apparent_power = p ./ pf;
% Calculate the reactive power for each apparent power value
reac = sqrt(apparent_power.^2 - p.^2);
% Calculate the inductive and capacitive reactive power for each value
inductive_power = reac / 2;
capacitive_power = reac / 2;
% Calculate the inductance and capacitance for each value
inductance = inductive_power ./ (2*pi*f*V^2);
capacitance = 1 ./ (2*pi*f*V^2*inductance);
% Return the reactive power array
reac = inductive_power + capacitive_power;
end
%Here is a modified version of the MATLAB function that returns separate arrays for inductive and capacitive reactive power:
function [ind, cap] = calc_reactiver(p)
% Calculates the inductive and capacitive reactive power for an array of active power values.
% Assumes a power factor of 0.85 and a frequency of 50 Hz.
% Constants for the calculation
pf = 0.85;
f = 50; % Hz
V = 10000; % V (assuming a line-to-line voltage of 10 kV)
% Calculate the apparent power for each active power value
apparent_power = p ./ pf;
% Calculate the reactive power for each apparent power value
reactive_power = sqrt(apparent_power.^2 - p.^2);
% Calculate the inductive and capacitive reactive power for each value
ind = reactive_power / 2;
cap = reactive_power / 2;
% Calculate the inductance and capacitance for each value
inductance = ind ./ (2*pi*f*V^2);
capacitance = 1 ./ (2*pi*f*V^2*inductance);
% Return the inductive and capacitive reactive power arrays
end
% This will calculate the corresponding reactive power values and display them in the command window.