IfArr = [0.06 0.16 0.18 0.22 0.29 0.36 0.42];
EfArr = [75 176 210 250 320 380 420]/sqrt(3); % divide by sqrt(3) to get line-neutral values
coeffs = polyfit(IfArr, EfArr, 2)
-380.7657 747.3807 -2.2177
fittedPoly = @(x) (coeffs(1)*x.^2 + coeffs(2)*x + coeffs(3));
% Creating virtual data using fitted polynomial
IfApprox = linspace(0, 1, 1e5);
EfApprox = fittedPoly(IfApprox);
legend('Experimental', 'Approximated')
title("I{f} vs. E{af} Characteristics")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
saveas(gcf, "E.3.b.grid.emf")
saveas(gcf, "E.3.b.grid.png")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
S_mag = 150e3; % by definition
VtA = 120; % by definition
R_armature = 0.7/500; % measured
R_field = 190/500; % measured
ztot = R_armature + xg + xs;
ztotPolar = getPolar(ztot);
phi = acos(pf); % radians
iA = iA_mag*cos(phi) - j*sin(phi);
eaf = VtA + iA*ztot
eaf = 1.2058e+02 + 1.2500e+02i
eafPolar = getPolar(eaf)
eafPolar = "173.682β 46.030Β°"
corrIf = immersiveFinder(EfArr, IfArr, abs(eaf))
Ploss = 3 *( ((abs(iA))^2)*R_armature + (corrIf^2)*R_field ) % I^2R_arm + If^2R_field
efficiency = (P/(P + Ploss))*100
maximumAllovedVpcc = VtA*1.10 % %10 more of rated value
vpcc = VtA + iA*xg
vpcc = 1.2000e+02 + 8.3333e+01i
vpccPolar = getPolar(vpcc) % yeah, it exceeds the allowed range
vpccPolar = "146.097β 34.778Β°"
[eafSig, tSig] = getSigFromPhasor(eaf, 60e-3);
[vpccSig, ~] = getSigFromPhasor(vpcc, 60e-3);
[vtASig, ~] = getSigFromPhasor(VtA, 60e-3);
[iASig, ~] = getSigFromPhasor(iA, 60e-3);
plot(tSig*1e3, vpccSig,"b-")
plot(tSig*1e3, vtASig, "c-")
title('E_{af}, V_{pcc}, V_t and I_{a} phasors versus time plot')
legend('E_{af}', 'V_{pcc}', 'V_t', 'I_a')
% https://www.mathworks.com/matlabcentral/fileexchange/70244-polar-phasors
function [ pas ] = spplot(varargin)
figure1=figure('Position', [0, 0, 1024, 1200]);
clrs = {[0 0.4470 0.7410], [0.8500 0.3250 0.0980], [0.9290 0.6940 0.1250], [0.4940 0.1840 0.5560],[0.4660 0.6740 0.1880],[0.3010 0.7450 0.9330], [0.6350 0.0780 0.1840]};
vinkel = @(x) exp(1i*x*pi/180);
plot=dummyX*vinkel(Vinkel);
max_lim = abs(Laengde)*Scale ;
x_fake=[0 max_lim 0 -max_lim];
y_fake=[max_lim 0 -max_lim 0];
h_fake=compass(x_fake,y_fake);
set(h_fake,'Visible','off');
set(findall(gcf, 'String', '30', '-or','String','60') ,'String', ' ');
set(findall(gcf, 'String', '0'),'String', ' ' );
set(findall(gcf, 'String', '330'),'String', ' ');
set(findall(gcf, 'String', '300'),'String', ' ' );
set(findall(gcf, 'String', '270'),'String', ' ');
set(findall(gcf, 'String', '240'),'String', ' ' );
set(findall(gcf, 'String', '210'),'String', ' ');
set(findall(gcf, 'String', '180'),'String', ' ');
set(findall(gcf, 'String', '150'),'String', ' ' );
set(findall(gcf, 'String', '120'),'String', ' ');
set(findall(gcf, 'String', '90'),'String', ' ' );
for m=0:0.5:abs(Laengde)*2
set(findall(gcf, 'String', [' ' num2str(m)]),'String', ' ');
if 150 > Vinkel && Vinkel >= 0
text(real(plot)+2,imag(plot)+2,[ num2str(abs(Laengde)) ' {\angle} ' num2str(Vinkel) '^{\circ}' ])
elseif 360 > Vinkel && Vinkel >= 210
text(real(plot)-2,imag(plot)-2,[ num2str(abs(Laengde)) ' {\angle} ' num2str(Vinkel) '^{\circ}' ])
elseif 210 > Vinkel && Vinkel >= 150
text(real(plot)-2,imag(plot)+2,[ num2str(abs(Laengde)) ' {\angle} ' num2str(Vinkel) '^{\circ}' ])
text(real(plot)-2,imag(plot)-2,[ num2str(abs(Laengde)) ' {\angle} ' num2str(Vinkel) '^{\circ}' ])
x_fake=[0 max_lim 0 -max_lim];
y_fake=[max_lim 0 -max_lim 0];
h_fake=compass(x_fake,y_fake);
vinkel = @(x) exp(1i*x*pi/180);
plot=dummyX*vinkel(Vinkel);
set(h_fake,'Visible','off');
text(real(plot)*1.15,imag(plot)*1.15,[pre])
xt = @(t) Laengde1.*sin(2*pi*t-(deg2rad(Vinkel1)));
string=strcat(num2str(Laengde1,'%100.2f'),' \angle ',num2str(Vinkel1,'%100.2f'),'^{\circ}');
string1=strcat(pre, 32 ,num2str(abs(Laengde1),'%100.2f'), 32 , enhed , 32 ,' {\angle} ', num2str(Vinkel1,'%100.2f'), '^{\circ}' );
ax.XTickLabel = {'0^\circ','90^\circ','180^\circ','270^\circ','360^\circ','450^\circ','540^\circ','630^\circ','720^\circ'};
p2(1).DisplayName=string1;