For the sinusoidal source emf, the impedances and their phases are calculated. % Phases [degrees] % INPUT time to calculate phasors tP = 0.75*tMax; nP = find(t > tP,1); phi_vS = rad2deg(angle(vS(nP))); phi_vR = phi_vL = rad2deg(angle(vL(nP))); theta_iS = rad2deg(angle(iS(nP))); if flagV == 4 [iS_Peaks, t_Peaks] = findpeaks(real(iS)); nPeaks = length(t_Peaks)-1; T_Peaks = (t(t_Peaks(end)) - f_Peaks = 1 / T_Peaks; ZR = R; ZL = 1j * w*L; Z = ZR + ZL; Zmag = abs(Z); phi_ZR = rad2deg(angle(ZR)); phi_ZL = rad2deg(angle(ZL)); phi_Z = rad2deg(angle(Z)); end For accurate results the time increment should be chosen so that
For the sinusoidal source emf, the impedances and their phases are calculated. % Phases [degrees] % INPUT time to calculate phasors tP = 0.75*tMax; nP = find(t > tP,1); phi_vS = rad2deg(angle(vS(nP))); phi_vR = phi_vL = rad2deg(angle(vL(nP))); theta_iS = rad2deg(angle(iS(nP))); if flagV == 4 [iS_Peaks, t_Peaks] = findpeaks(real(iS)); nPeaks = length(t_Peaks)-1; T_Peaks = (t(t_Peaks(end)) - f_Peaks = 1 / T_Peaks; ZR = R; ZL = 1j * w*L; Z = ZR + ZL; Zmag = abs(Z); phi_ZR = rad2deg(angle(ZR)); phi_ZL = rad2deg(angle(ZL)); phi_Z = rad2deg(angle(Z)); end For accurate results the time increment should be chosen so that
CNRL.docx